Skip to content

Commit 80060cd

Browse files
committed
java filesystem_type file
1 parent 63f4c7e commit 80060cd

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

+stdlib/+java/filesystem_type.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function t = filesystem_type(p)
2+
3+
t = javaMethod("getFileStore", "java.nio.file.Files", javaPathObject(p)).type;
4+
5+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
%% JAVAPATHOBJECT Return a Java nio.file.Path object for a given file path.
2+
function o = javaPathObject(p)
3+
4+
o = javaMethod("get", "java.nio.file.Paths", p, javaArray('java.lang.String', 0));
5+
6+
% o = javaObject("java.io.File", p).toPath();
7+
% javaArray way about 20% faster
8+
9+
end

+stdlib/filesystem_type.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
t = System.IO.DriveInfo(stdlib.absolute(p)).DriveFormat;
1313
% https://learn.microsoft.com/en-us/dotnet/api/system.io.driveinfo.driveformat
1414
elseif stdlib.has_java()
15-
t = javaMethod("getFileStore", "java.nio.file.Files", javaPathObject(p)).type;
15+
t = stdlib.java.filesystem_type(p);
1616
elseif stdlib.has_python()
1717
t = stdlib.python.filesystem_type(p);
1818
end

0 commit comments

Comments
 (0)