File tree Expand file tree Collapse file tree 3 files changed +93
-0
lines changed Expand file tree Collapse file tree 3 files changed +93
-0
lines changed Original file line number Diff line number Diff line change @@ -1555,6 +1555,51 @@ os.isLink(wd / "misc/folder-symlink") ==> true
15551555os.isLink(wd / "folder1") ==> false
15561556----
15571557
1558+ ==== `os.isReadable`
1559+
1560+ [source,scala]
1561+ ----
1562+ os.isReadable(p: Path): Boolean
1563+ ----
1564+
1565+ Returns `true` if the given path is readable.
1566+
1567+ [source,scala]
1568+ ----
1569+ os.isReadable(wd / "misc/file1") ==> false
1570+ os.isReadable(wd / "misc/file2") ==> true
1571+ ----
1572+
1573+ ==== `os.isWritable`
1574+
1575+ [source,scala]
1576+ ----
1577+ os.isWritable(p: Path): Boolean
1578+ ----
1579+
1580+ Returns `true` if the given path is writable.
1581+
1582+ [source,scala]
1583+ ----
1584+ os.isWritable(wd / "misc/file1") ==> false
1585+ os.isWritable(wd / "misc/file2") ==> true
1586+ ----
1587+
1588+ ==== `os.isExecutable`
1589+
1590+ [source,scala]
1591+ ----
1592+ os.isExecutable(p: Path): Boolean
1593+ ----
1594+
1595+ Returns `true` if the given path is executable.
1596+
1597+ [source,scala]
1598+ ----
1599+ os.isExecutable(wd / "misc/file1") ==> false
1600+ os.isExecutable(wd / "misc/file2.sh") ==> true
1601+ ----
1602+
15581603==== `os.size`
15591604
15601605[source,scala]
Original file line number Diff line number Diff line change @@ -40,6 +40,33 @@ object isDir extends Function1[Path, Boolean] {
4040 }
4141}
4242
43+ /**
44+ * Checks whether the given path is readable
45+ *
46+ * Returns `false` if the path does not exist
47+ */
48+ object isReadable extends Function1 [Path , Boolean ] {
49+ def apply (p : Path ): Boolean = Files .isReadable(p.wrapped)
50+ }
51+
52+ /**
53+ * Checks whether the given path is writable
54+ *
55+ * Returns `false` if the path does not exist
56+ */
57+ object isWritable extends Function1 [Path , Boolean ] {
58+ def apply (p : Path ): Boolean = Files .isWritable(p.wrapped)
59+ }
60+
61+ /**
62+ * Checks whether the given path is executable
63+ *
64+ * Returns `false` if the path does not exist
65+ */
66+ object isExecutable extends Function1 [Path , Boolean ] {
67+ def apply (p : Path ): Boolean = Files .isExecutable(p.wrapped)
68+ }
69+
4370/**
4471 * Gets the size of the given file or folder
4572 *
Original file line number Diff line number Diff line change @@ -50,6 +50,27 @@ object FilesystemMetadataTests extends TestSuite {
5050 os.isLink(wd / " folder1" ) ==> false
5151 }
5252 }
53+ test(" isReadable" ) {
54+ test - prep { wd =>
55+ os.isReadable(wd / " File.txt" ) ==> true
56+ os.isReadable(wd / " folder1" ) ==> true
57+ }
58+ }
59+ test(" isWritable" ) {
60+ test - prep { wd =>
61+ os.isWritable(wd / " File.txt" ) ==> true
62+ os.isWritable(wd / " folder1" ) ==> true
63+ }
64+ }
65+ test(" isExecutable" ) {
66+ test - prep { wd =>
67+ if (Unix ()) {
68+ os.perms.set(wd / " File.txt" , " rw-rw-rw-" )
69+ os.isExecutable(wd / " File.txt" ) ==> false
70+ os.isExecutable(wd / " misc/echo" ) ==> true
71+ }
72+ }
73+ }
5374 test(" size" ) {
5475 test - prep { wd =>
5576 os.size(wd / " File.txt" ) ==> 8
You can’t perform that action at this time.
0 commit comments