NSFileManager fileExistsAtPath: & symbolic links

In my ~ / Library / Caches / directory, I have a symbolic link to my application package, and some symbolic links to images (for example, "big_picture.png") a symbolic link to "small_picture.png"). When I try to check if symbolic links exist using the NSFileManager method fileExistsAtPath:, it returns NOeven if a symbolic link exists, and also refers to a file that exists.

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

+3
source share
1 answer

fileExistsAtPath may follow a symbolic link. Perhaps you can try another method - use attributesOfItemAtPath:error:. The dictionary will be returned if the file exists, and it will give you the opportunity to check the file type. To do the latter, call fileTypein the dictionary and check it on NSFileTypeSymbolicLink.

+9
source

Source: https://habr.com/ru/post/1762270/


All Articles