Reputation: 1027
On macOS, /tmp is a symlink to /private/tmp, yet when I do this:
URL(fileURLWithPath: "/tmp").resolvingSymlinksInPath().path
it returns "/tmp"
.
(I've reported this to Apple, and they closed it as a duplicate, so they know about it already.)
Is it publicly known what paths have incorrect values returned by this method? If it's just a couple paths which are hardcoded internally, then it'd be easier to check for them, than to rewrite a working resolvingSymlinksInPath() from scratch.
Upvotes: 0
Views: 451
Reputation: 53000
See the documentation for resolvingSymlinksInPath
:
If the name of the receiving path begins with /private, this property strips off the /private designator, provided the result is the name of an existing file.
So if the result is, say, /private/var
and there is /var
then that is what is returned.
This appears to be based on a convention only, there is no check that the resultant path references the same filesystem item. E.g. create /a
, /private/a
and sym link /test
to /private/a
then resolve symlinks for /test
and the result is /a
despite that not being the same as /private/a
Upvotes: 2