mik*_*wan 0 macos cocoa nsfilemanager
我正在研究管理文档的程序.我的应用程序所做的一件事是从互联网下载文档并打开它们.我下载的这些文件需要以只读权限打开.
所以,我想知道是否有一种以编程方式设置文件权限的方法.
提前致谢.
除了chmod
通过@Vlad提到的,你也可以使用setAttributes:ofItemAtPath:error:
的方法NSFileManager
用的属性NSFileImmutable
:
NSDictionary* attribs = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:NSFileImmutable];
[[NSFileManager defaultManager] setAttributes: attribs ofItemAtPath:@"/path/to/file" error:nil];
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1432 次 |
最近记录: |