http://hi.baidu.com/lm382304817/blog/item/b12c70e26851103eb8382032.html
filePath:文件路径
NSDictionary *fileAttributes = [[NSFileManager defaultManager] fileAttributesAtPath:filePath traverseLink:YES]; NSNumber *num = [fileAttributes objectForKey:NSFilePosixPermission]; NSLog(@"%04o", [num unsignedLongValue]); 这样就输出了该文件的权限,是用4位八进制数输出的,方便查看 给文件设置权限的话就是一个逆过程: filePath:文件路径 NSDictionary *theAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInteger:0555], NSFilePosixPermission,nil]; NSError *theError; [[NSFileManager defaultManager] setAttributes:theAttributes ofItemAtPath:filePath error:&theError]; 这样就给文件写了一个0555的权限,至于有没有写成功就看它的返回值了,错误信息在theError里。 |