Skip to content

Commit ef3629c

Browse files
committed
samepath .net
1 parent 700d05b commit ef3629c

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

+stdlib/is_symlink.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
ok = ~isempty(System.IO.FileInfo(p).LinkTarget);
1717
else
1818
attr = string(System.IO.File.GetAttributes(p).ToString());
19-
% https://learn.microsoft.com/en-us/dotnet/api/system.io.fileattributesN
19+
% https://learn.microsoft.com/en-us/dotnet/api/system.io.fileattributes
2020
% ReparsePoint is for Linux, macOS, and Windows
2121
ok = contains(attr, 'ReparsePoint');
2222
end

+stdlib/samepath.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
y = e1 == 0 && e2 == 0 && ...
2929
r1.ino == r2.ino && r1.dev == r2.dev;
3030

31+
elseif stdlib.has_dotnet()
32+
separators = [System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar];
33+
f1 = System.IO.Path.GetFullPath(path1).TrimEnd(separators);
34+
f2 = System.IO.Path.GetFullPath(path2).TrimEnd(separators);
35+
y = System.String.Equals(f1, f2, System.StringComparison.OrdinalIgnoreCase);
3136
elseif stdlib.has_java() && stdlib.java_api() >= 11
3237
% https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/nio/file/Files.html#isSameFile(java.nio.file.Path,java.nio.file.Path)
3338
% Java 1.8 is buggy in some corner cases, so we require at least 11.

test/TestFileImpure.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
p_same = {...
77
{"..", "./.."}, ...
8-
{"..", pwd() + "/.."}}
8+
{"..", pwd() + "/.."}, ...
9+
{pwd(), pwd() + "/."}}
910

1011
ph = {{0, '"stdin"'}, {1, '"stdout"'}, {2, '"stderr"'}, {fopen(tempname()), ''}}
1112

0 commit comments

Comments
 (0)