File tree Expand file tree Collapse file tree 4 files changed +27
-9
lines changed Expand file tree Collapse file tree 4 files changed +27
-9
lines changed Original file line number Diff line number Diff line change 1- function i = device_dotnet (path )
1+ function i = device (path )
22
3+ i = [];
34
45h = NET .addAssembly(' System.Management' );
56
Original file line number Diff line number Diff line change 1+ function i = device(p )
2+
3+
4+ if ispc()
5+ cmd = " powershell -Command (Get-CimInstance -ClassName Win32_Volume -Filter 'DriveLetter = \"" + p(1) + " \" ').DeviceID" ;
6+ elseif ismac()
7+ cmd = " stat -f %d " + p ;
8+ elseif isunix()
9+ cmd = " stat -c %d " + p ;
10+ end
11+
12+
13+ [s , m ] = system(cmd );
14+ if s == 0
15+ i = str2double(m );
16+ end
17+
18+ end
Original file line number Diff line number Diff line change 1010if stdlib .has_python()
1111 i = stdlib .python .device(p );
1212elseif ispc() && stdlib .has_dotnet()
13- i = device_dotnet(p );
14- elseif stdlib .isoctave()
15- [s , err ] = stat(p );
16- if err == 0
17- i = s .dev ;
18- end
13+ i = stdlib .dotnet .device(p );
1914elseif isunix() && stdlib .java_api() >= 11
2015 % Java 1.8 is buggy in some corner cases, so we require at least 11.
2116 opt = javaMethod(" values" , " java.nio.file.LinkOption" );
2217 i = java .nio .file .Files .getAttribute(javaPathObject(p ), " unix:dev" , opt );
2318end
2419
20+ if isempty(i )
21+ i = stdlib .sys .device(p );
22+ end
23+
24+ i = uint64(i );
25+
2526end
2627
2728% !assert(device(pwd) >= 0);
Original file line number Diff line number Diff line change @@ -64,8 +64,6 @@ function test_filesystem_type(tc, Ps)
6464
6565function test_device(tc )
6666
67- tc .assumeTrue(stdlib .has_python() || (ispc() && stdlib .has_dotnet()) || (isunix() && stdlib .java_api() >= 11 ))
68-
6967if ispc()
7068 tc .verifyGreaterThan(stdlib .device(pwd()), 0 )
7169else
You can’t perform that action at this time.
0 commit comments