File tree Expand file tree Collapse file tree 3 files changed +29
-24
lines changed Expand file tree Collapse file tree 3 files changed +29
-24
lines changed Original file line number Diff line number Diff line change 11%% FILESYSTEM_TYPE tell type of filesystem
2- % requires : java
2+ % optional : java
33%
4- % example outputs: ntfs, ext4, apfs, ...
5- %
6- % if empty output or error, try specifying the drive root
7- % like "/" or "C:/"
4+ % example outputs: NTFS, ext4, apfs, ...
85
96function t = filesystem_type(p )
107arguments
11- p {mustBeTextScalar } = ' '
8+ p {mustBeTextScalar }
129end
1310
14- op = javaPathObject(p );
11+ t = " " ;
12+ if ~stdlib .exists(p ), return , end
1513
16- if stdlib .isoctave ()
17- t = javaMethod( " getFileStore " , " java.nio.file.Files " , op ).type ;
14+ if ispc ()
15+ t = string( System . IO .DriveInfo( stdlib .absolute( p )).DriveFormat) ;
1816else
19- t = java .nio .file .Files .getFileStore(op ).type.string;
20- end
17+ op = javaPathObject(p );
2118
19+ if stdlib .isoctave()
20+ t = javaMethod(" getFileStore" , " java.nio.file.Files" , op ).type;
21+ else
22+ t = java .nio .file .Files .getFileStore(op ).type.string;
23+ end
2224end
2325
2426% !assert(!isempty(filesystem_type(pwd)))
Original file line number Diff line number Diff line change @@ -33,5 +33,21 @@ function test_disk_capacity(tc, Ps)
3333end
3434end
3535
36+
37+ function test_filesystem_type(tc , Ps )
38+
39+ tc .assumeTrue(ispc() || stdlib .has_java())
40+
41+ s = stdlib .filesystem_type(Ps );
42+ tc .verifyClass(s , ' string' )
43+ L = strlength(s );
44+
45+ if stdlib .exists(Ps )
46+ tc .verifyGreaterThan(L , 0 )
47+ else
48+ tc .verifyEqual(L , 0 )
49+ end
50+ end
51+
3652end
3753end
Original file line number Diff line number Diff line change @@ -40,19 +40,6 @@ function test_owner(tc, Ps)
4040
4141methods (Test , TestTags = " java" )
4242
43- function test_filesystem_type(tc , Ps )
44-
45- s = stdlib .filesystem_type(Ps );
46- tc .verifyClass(s , ' string' )
47- L = strlength(s );
48-
49- if strlength(Ps ) == 0 || stdlib .exists(Ps )
50- tc .verifyGreaterThan(L , 0 )
51- else
52- tc .verifyEqual(L , 0 )
53- end
54- end
55-
5643function test_username(tc )
5744u = stdlib .get_username();
5845tc .verifyGreaterThan(strlength(u ), 0 )
You can’t perform that action at this time.
0 commit comments