2 problems managing symbolic links (linux / MacOS)


Problem on getLinkedTarget:
In a symbolic link, relative link target refer to the directory in which the link resides.
If symbolic link point to an absolute path, File( link_file).getLinkedTarget() return the correct path; but if symbolic link point to a relative path it return /target_path

in /tmp I create a symbolic link:
ln -s file /tmp/link
now I change directory (ie. /home/my_user)
If I try to read the link target with File("/tmp/link").getLinkTarget(), I have a File object with path /home/my_user/file and not /tmp/file

I have a symbolic link (ie. /tmp/link) that point to a file (ie. /tmp/real_file)

If I call File("/tmp/link").deleteFile() the symbolic link is deleted.
But if the link refer to a not existent path, if I call File("/tmp/link").deleteFile() the link is not deleted. In other words I cannot delete symbolic links that point to non existent path.
This behaviour happen because File::exists (used on deleteFile) use the access function that deference symbolic links (so it will check access to a non existent path returning false). Probably is better to replace access with lstat.



Ok, thanks - I’ll sort something out…