Is there any API to check whether a file is a locked? I am not able to find any API in the NSFileManager
class.Let me know if there is any API to check the lock of
If necessary, the immutable flag (OS X 'file locked') can also be determined with POSIX C functions. The immutable property is not a lock in unix terms but a file flag. It can be obtained with the stat
function:
struct stat buf;
stat("my/file/path", &buf);
if (0 != (buf.st_flags & UF_IMMUTABLE)) {
//is immutable
}
For reference see: https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man2/stat.2.html
The immutable flag can be set with the chflags
function:
chflags("my/file/path", UF_IMMUTABLE);
For reference see: https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man2/chflags.2.html