Setting file permissions in Objective-C

2020-04-21 04:40发布

问题:

I managed to get my hands on a nifty ftp object. It is very low level and easy to adapt. I'm using it to transfer files from one Mac to another via FTP.

Now, the issue I'm having is that when the file, that is transfered, reaches its destination, the other Mac, the access permissions is set , at random intervals, to "Everyone" : "No Access". So sometimes, whatever I do with the files fails randomly because my application can't access the files.

Is there a way I can change the file's access permissions in Objective-C?

Regards, EZFrag

回答1:

For permissons of local files, you'd want [NSFileManager setAttributes:ofItemAtPath:error:]

And the attribute dictionary you'd want to use would include NSFilePosixPermissions.