How to change file permissions from Cocoa ?
22/11/03 10:29
Is there a Cocoa call to access and modify file permissions ?
NSFileManager has the instance method - (BOOL)changeFileAttributes:(NSDictionary *)attributes atPath:(NSString *)path. The key to set file permissions is NSFilePosixPermissions and its value must be a NSNumber with an int value, the 9 right most bits describing the permissions.
You can also use the Carbon functions FSGetCatalogInfo and FSSetCatalogInfo, but you probably don't want to link to Carbon only for that purpose, and of course the POSIX functions chmod and fchmod. (man 2 chmod).
Authored by: gekko513 on Saturday, February 05 2005 @ 04:20 AM GMT
So, why will no-one say what the specific bits in this number should be.
Since you say it uses the 9 last bits, I have to assume it is the rwxrwxrwx
pattern that I know from the shell, but is this assumption correct and is it
in the user, group, all order with the least significant bit being the eXecute
for all or is the least significant bit the Read for user?
You can also use the Carbon functions FSGetCatalogInfo and FSSetCatalogInfo, but you probably don't want to link to Carbon only for that purpose, and of course the POSIX functions chmod and fchmod. (man 2 chmod).
Authored by: gekko513 on Saturday, February 05 2005 @ 04:20 AM GMT
So, why will no-one say what the specific bits in this number should be.
Since you say it uses the 9 last bits, I have to assume it is the rwxrwxrwx
pattern that I know from the shell, but is this assumption correct and is it
in the user, group, all order with the least significant bit being the eXecute
for all or is the least significant bit the Read for user?