Now I use this code:
NSDictionary* attr = [[NSFileManager defaultManager] fileAttributesAtPath:file traverseLink:YES];
and get a warning:
'fileAttributesAtPath:traverseLink:' is deprecated
Who knows what to use instead?
Thanks!
Use attributesOfItemAtPath:error: instead.
attributesOfItemAtPath:error:
use attributesOfItemAtPath:error:
NSError* error; NSDictionary* attr = [[NSFileManager defaultManager] attributesOfItemAtPath:file error:&error];
The accepted answer forgot to process traverseLink:YES from the question.
traverseLink:YES
The improved answer uses both attributesOfItemAtPath:error: and stringByResolvingSymlinksInPath :
stringByResolvingSymlinksInPath
NSDictionary* attr = [[NSFileManager defaultManager] attributesOfItemAtPath:[file stringByResolvingSymlinksInPath] error:nil];
Special considerations
Since this method does not return error information, it is deprecated like Mac OS X v10.5. Use setAttributes: ofItemAtPath: error: instead.
link
you should read the documentation :
fileAttributesAtPath: traverseLink:Returns a dictionary that describes the attributes of the POSIX file specified in the specified. (Deprecated on Mac OS X v10.5. AttributesOfItemAtPath: error: instead.)
fileAttributesAtPath: traverseLink:
Returns a dictionary that describes the attributes of the POSIX file specified in the specified. (Deprecated on Mac OS X v10.5. AttributesOfItemAtPath: error: instead.)