DirectoryIterator and Mac Alias


#1

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?

 


#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?


#3

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?


#4

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).


#5

bump


#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..


#7

You need to use  FSPathMakeRef, FSResolveAliasFileWithMountFlags and FSRefMakePath
 


#8

See 

http://www.juce.com/forum/topic/alias-ans-shortcut-resolution


#9

Awesome, thanks a lot!


#10

Those were all deprecated long ago, weren't they?


#11

Yep. Working fine though.

 

Here is the new way (untested)

 

http://stackoverflow.com/questions/24870288/how-i-can-modernize-deprecated-fspathmakeref-fsisaliasfile-fsresolvealiasfilew