开发者

Get and set owner, group and permissions in Cocoa

开发者 https://www.devze.com 2023-03-01 11:07 出处:网络
I am looking how to get (and set) owner, group and permissions in Cocoa for a given file. What is the best way to do this? (and how to check if the current user is granted enough开发者_如何学编程 to

I am looking how to get (and set) owner, group and permissions in Cocoa for a given file.

What is the best way to do this? (and how to check if the current user is granted enough开发者_如何学编程 to change these permissions)

Thanks for your help,

Regards,


NSFileManager has a method -setAttributes:OfItemAtPath:error: which will do the trick. Check out particularly the NSFilePosixPermissions key. If the method fails, it returns false and the details of the error are placed in the NSError** you give it.

0

精彩评论

暂无评论...
验证码 换一张
取 消