File tree Expand file tree Collapse file tree 3 files changed +23
-20
lines changed Expand file tree Collapse file tree 3 files changed +23
-20
lines changed Original file line number Diff line number Diff line change 11%% DISK_AVAILABLE disk available space (bytes)
2- % requires : mex or java
2+ % optional : mex
33%
44% example: stdlib.disk_available('/')
55%
1010 d {mustBeTextScalar }
1111end
1212
13- f = javaFileObject(d ).getUsableSpace();
14-
15- f = uint64(f );
13+ f = uint64(0 );
14+ if ~stdlib .exists(d ), return , end
1615
16+ if ispc()
17+ f = System .IO .DriveInfo(stdlib .absolute(d )).AvailableFreeSpace();
18+ else
19+ f = javaFileObject(d ).getUsableSpace();
20+ f = uint64(f );
1721end
1822
1923% !assert (disk_available('.') > 0)
Original file line number Diff line number Diff line change 11%% DISK_CAPACITY disk total capacity (bytes)
2- % requires : mex or java
2+ % optional : mex
33%
44% example: stdlib.disk_capacity('/')
55
88 d {mustBeTextScalar }
99end
1010
11- f = javaFileObject(d ).getTotalSpace();
11+ f = uint64(0 );
12+ if ~stdlib .exists(d ), return , end
1213
13- f = uint64(f );
14+ if ispc()
15+ f = System .IO .DriveInfo(stdlib .absolute(d )).TotalSize();
16+ else
17+ f = javaFileObject(d ).getTotalSpace();
18+ f = uint64(f );
19+ end
1420
1521end
1622
Original file line number Diff line number Diff line change 44Ps = {" ." , " " , " not-exist" }
55end
66
7- methods (Test , TestTags = [" mex" ])
8-
9- function test_mex_disk_available(tc )
10- tc .assertTrue(stdlib .is_mex_fun(" stdlib.disk_available" ))
11- end
12-
13- function test_mex_disk_capacity(tc )
14- tc .assertTrue(stdlib .is_mex_fun(" stdlib.disk_capacity" ))
15- end
16-
17- end
18-
19- methods (Test , TestTags = [" java" ])
7+ methods (Test )
208
219function test_disk_available(tc , Ps )
2210
11+ tc .assumeTrue(ispc() || stdlib .has_java() || stdlib .is_mex_fun(" stdlib.disk_available" ))
12+
2313zero = uint64(0 );
2414
2515if stdlib .exists(Ps )
@@ -29,8 +19,11 @@ function test_disk_available(tc, Ps)
2919end
3020end
3121
22+
3223function test_disk_capacity(tc , Ps )
3324
25+ tc .assumeTrue(ispc() || stdlib .has_java() || stdlib .is_mex_fun(" stdlib.disk_capacity" ))
26+
3427zero = uint64(0 );
3528
3629if stdlib .exists(Ps )
You can’t perform that action at this time.
0 commit comments