Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSFileManager fileExistsAtPath: & symbolic links

In my ~/Library/Caches/ directory, I have a symbolic link to my app's bundle, and some symbolic links to images (e.g. "big_picture.png" is a symlink to "small_picture.png"). When I try to check if the symlinks exist, using the NSFileManager's fileExistsAtPath: method, it returns NO, even when the symlink does exist, and it links to a file that exists as well.

As far as I know, Apple's documentation claims that what I'm trying to do should work. Am I doing something wrong, or is this a bug?

like image 994
ryyst Avatar asked Aug 30 '10 11:08

ryyst


1 Answers

fileExistsAtPath might follow the symlink. Maybe you can try a different method -- Use attributesOfItemAtPath:error:. A dictionary will be returned if the file exists, and it will give you the ability to check the file type. To do the latter, call fileType on the dictionary and check it against NSFileTypeSymbolicLink.

like image 161
Max Seelemann Avatar answered Oct 04 '22 12:10

Max Seelemann