File tree Expand file tree Collapse file tree 4 files changed +14
-15
lines changed Expand file tree Collapse file tree 4 files changed +14
-15
lines changed Original file line number Diff line number Diff line change 11%% HARD_LINK_COUNT get the number of hard links to a file
2- % requires: java
2+ %
33%
44% Ref:
55% * https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/nio/file/Files.html#getPosixFileAttributes(java.nio.file.Path,java.nio.file.LinkOption...)
1212
1313c = [];
1414
15- if stdlib .isoctave()
15+ if stdlib .has_python()
16+ c = uint64(py .pathlib .Path(p ).stat().st_nlink);
17+ elseif stdlib .isoctave()
1618 [s , err ] = stat(p );
1719 if err == 0
1820 c = s .nlink ;
1921 end
20- elseif isunix()
22+ elseif isunix() && stdlib .has_java()
2123 opt = javaMethod(" values" , " java.nio.file.LinkOption" );
2224 c = java .nio .file .Files .getAttribute(javaPathObject(p ), " unix:nlink" , opt );
2325end
Original file line number Diff line number Diff line change 11%% INODE filesystem inode of path
2- % requires: java
2+ %
33% Windows always returns 0, Unix returns inode number.
44
55function i = inode(path )
Original file line number Diff line number Diff line change @@ -34,6 +34,14 @@ function test_disk_capacity(tc, Ps)
3434end
3535
3636
37+ function test_hard_link_count(tc )
38+ tc .assumeTrue(stdlib .has_python() || (isunix() && stdlib .has_java()))
39+ fn = mfilename(" fullpath" ) + " .m" ;
40+
41+ tc .verifyGreaterThanOrEqual(stdlib .hard_link_count(fn ), 1 )
42+ end
43+
44+
3745function test_filesystem_type(tc , Ps )
3846
3947tc .assumeTrue(stdlib .has_dotnet() || stdlib .has_java())
Original file line number Diff line number Diff line change @@ -21,17 +21,6 @@ function test_java_api(tc)
2121end
2222
2323
24- function test_hard_link_count(tc )
25- fn = mfilename(" fullpath" ) + " .m" ;
26-
27- if ispc
28- tc .verifyEmpty(stdlib .hard_link_count(fn ))
29- else
30- tc .verifyGreaterThanOrEqual(stdlib .hard_link_count(fn ), 1 )
31- end
32- end
33-
34-
3524function test_cpu_load(tc )
3625tc .verifyGreaterThanOrEqual(stdlib .cpu_load(), 0 )
3726end
You can’t perform that action at this time.
0 commit comments