我想以八进制显示文件的权限。下面的代码有效,但仅以十进制显示权限。任何想法如何将结果转换为八进制?%o 没有显示正确的结果。
NSString *path=@"/somepath";
NSFileManager *fm = [NSFileManager defaultManager];
NSArray *contents = [fm contentsOfDirectoryAtPath:path error:NULL];
NSString* fullPath = nil;
for(NSString* node in contents) {
fullPath = [NSString stringWithFormat:@"%@%@",path,node];
NSDictionary *fileAttributes = [fm attributesOfItemAtPath:fullPath error:NULL];
unsigned *posix=(unsigned *)[fileAttributes valueForKey:NSFilePosixPermissions];
NSLog(@"Permissions:%@", posix); //shows 420 decimal. I need to show 644 octal
}
谢谢