Skip to content

Commit 6aa9bac

Browse files
committed
filesystem_type python fallback
1 parent 63c6916 commit 6aa9bac

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

+stdlib/+python/filesystem_type.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function t = filesystem_type(p)
2+
3+
t = string.empty;
4+
5+
pr = stdlib.absolute(p);
6+
7+
try
8+
for part = py.psutil.disk_partitions(p)
9+
prt = part{1};
10+
if startsWith(pr, string(prt.mountpoint))
11+
t = string(prt.fstype);
12+
return
13+
end
14+
end
15+
catch e
16+
warning(e.identifer, "%s", e.message)
17+
end
18+
19+
end

+stdlib/filesystem_type.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
% https://learn.microsoft.com/en-us/dotnet/api/system.io.driveinfo.driveformat
1414
elseif stdlib.has_java()
1515
t = javaMethod("getFileStore", "java.nio.file.Files", javaPathObject(p)).type;
16+
elseif stdlib.has_python()
17+
t = stdlib.python.filesystem_type(p);
1618
end
1719

1820
if strempty(p)

0 commit comments

Comments
 (0)