iPhone SDK开发 文件权限获取及修改
来源:互联网 发布:淘宝添加客服的代码 编辑:程序博客网 时间:2024/05/02 04:57
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里。
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里。
- iPhone SDK开发 文件权限获取及修改
- linux文件权限及修改
- linux文件权限及修改
- iPhone SDK开发 使应用程序获得root权限
- iphone开发--获取系统配置文件内容
- Linux修改文件及文件夹权限(转)
- Linux修改文件及文件夹权限
- 递归修改子目录及文件的权限
- Linux修改文件及文件夹权限
- Linux修改文件及文件夹权限
- linux文件权限查看及修改
- Linux修改文件及文件夹权限
- Linux修改文件及文件夹权限
- Linux修改文件及文件夹权限
- Linux修改文件及文件夹权限
- Linux修改文件及文件夹权限 文件属性
- Linux修改文件及文件夹权限
- Ubuntu 文件权限 修改及查看
- 管理Activity的实例
- 程序员谈谈我的职场观(三)
- MINIGUI常见错误集及解决方法
- Java设计模式_创建模式_原型模式
- radioGroup监听
- iPhone SDK开发 文件权限获取及修改
- Solaris下C++安装环境的安装
- iPhone完整截屏
- xp下实现窗体透明特效SetLayeredWindowAttributes函数
- 防挂马
- Hibernate Session的delete方法
- combox值作为筛选条件
- vc 如何把多个工程建在一个工作空间里
- 摘要的写法