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. "开发者_JAVA技巧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?
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
.
精彩评论