Is there a way to make the DirectoryIterator go through Mac aliases (not symbolic links)?
The isLink() doesn't work (as I guess it's only for symbolic links), but even if I give the full path to the alias to the DirectoryIterator it can't find any files in it.
Suggestions?
jules
November 3, 2015, 8:05am
2
The DirectoryIterator won't do that (if it followed them then I think it could get into infinite loops)
Doesn't File::getLinkedTarget() return the aliased target though?
Unfortunately not.
I tried several times, not sure if I'm doing something wrong but basically this:
File dir = File("/path/to/alias");
File aliasDir = dir.getLinkedTarget();
DBG(dir.getFullPathName());
DBG(newDir.getFullPathName());
returns this:
/path/to/alias
/path/to/alias
No change at all. I think that getFileLink check only symbolic links and not aliases.
What can I do?
After further tests I can confirm that getLinkedTarget() works only on symbolic links and NOT on aliases.
How can I manage aliases? They are way more common than symbolic links (and also easier to manage).
jules
November 5, 2015, 3:47pm
6
Not really a priority for us to look at this, but it may be a one-liner if you want to do the research into how aliases work..
You need to use FSPathMakeRef, FSResolveAliasFileWithMountFlags and FSRefMakePath
See
http://www.juce.com/forum/topic/alias-ans-shortcut-resolution
jules
November 5, 2015, 4:30pm
10
Those were all deprecated long ago, weren't they?
Yep. Working fine though.
Here is the new way (untested)
http://stackoverflow.com/questions/24870288/how-i-can-modernize-deprecated-fspathmakeref-fsisaliasfile-fsresolvealiasfilew