SAMEPATH is path the same

true if inputs resolve to same path. Both paths must exist.

NOTE: in general on Windows same(".", "not-exist/..") is true, but on Unix it is false. In C/C++ access() or stat() the same behavior is observed Windows vs Unix.

Ref: https://devblogs.microsoft.com/oldnewthing/20220128-00/?p=106201

Contents

Inputs

function y = samepath(path1, path2, backend)
arguments
  path1 string
  path2 string
  backend (1,:) string = ["python", "java", "sys", "native"]
end

% For this function, Python is over 10x faster than Java

[fun, b] = hbackend(backend, "samepath");

if (isscalar(path1) && isscalar(path2)) || b == "native"
  y = fun(path1, path2);
else
  y = arrayfun(fun, path1, path2);
end

end