File tree Expand file tree Collapse file tree 7 files changed +77
-1
lines changed Expand file tree Collapse file tree 7 files changed +77
-1
lines changed Original file line number Diff line number Diff line change
1
+ function ok = exists(p )
2
+ %% exists does path exist
3
+ % https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/File.html#exists()
4
+
5
+ arguments
6
+ p (1 ,1 ) string
7
+ end
8
+
9
+
10
+ ok = java .io .File(p ).exists();
11
+
12
+ end
Original file line number Diff line number Diff line change
1
+ function ok = is_readable(file )
2
+ %% is_readable is file readable
3
+ % https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/nio/file/Files.html#isReadable(java.nio.file.Path)
4
+
5
+ arguments
6
+ file string {mustBeScalarOrEmpty }
7
+ end
8
+
9
+ if isempty(file )
10
+ ok = logical .empty ;
11
+ return
12
+ end
13
+
14
+
15
+ ok = java .nio .file .Files .isReadable(java .io .File(stdlib .fileio .absolute_path(file )).toPath());
16
+
17
+ end
Original file line number Diff line number Diff line change
1
+ function ok = is_writable(file )
2
+ %% is_writable is file writable
3
+ % https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/nio/file/Files.html#isWritable(java.nio.file.Path)
4
+
5
+ arguments
6
+ file string {mustBeScalarOrEmpty }
7
+ end
8
+
9
+ if isempty(file )
10
+ ok = logical .empty ;
11
+ return
12
+ end
13
+
14
+
15
+ ok = java .nio .file .Files .isWritable(java .io .File(stdlib .fileio .absolute_path(file )).toPath());
16
+
17
+ end
Original file line number Diff line number Diff line change
1
+ function ok = exists(p )
2
+ %% exists does path exist
3
+
4
+ arguments
5
+ p (1 ,1 ) string
6
+ end
7
+
8
+ ok = stdlib .fileio .exists(p );
9
+
10
+ end
Original file line number Diff line number Diff line change
1
+ function ok = is_readable(p )
2
+ %% is_readable() returns true if the file at path p is readable
3
+
4
+ arguments
5
+ p (1 ,1 ) string
6
+ end
7
+
8
+ ok = stdlib .fileio .is_readable(p );
9
+
10
+ end
Original file line number Diff line number Diff line change
1
+ function ok = is_writable(p )
2
+ %% is_writable() returns true if the file at path p is writable
3
+
4
+ arguments
5
+ p (1 ,1 ) string
6
+ end
7
+
8
+ ok = stdlib .fileio .is_writable(p );
9
+
10
+ end
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ function test_is_readable(tc)
35
35
function test_is_writable(tc )
36
36
37
37
tc .verifyTrue(stdlib .is_writable(pwd ))
38
- tc .verifyFalse(stdlib .is_writable(matlabroot ))
38
+ % tc.verifyFalse(stdlib.is_writable(matlabroot)) % on CI this can be writable!
39
39
tc .verifyFalse(stdlib .is_writable(" not-exists" ))
40
40
41
41
end
You can’t perform that action at this time.
0 commit comments