Given a file path how do i check that this file is owned by current user?
Currently i managed to get:
[[[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:outError] fileOwnerAccountID];
Which return NSNumber*. But i can’t seem to google for how to get current user account id to compare it with. Besides all this looks messy, there seem to be a better way to do it, no?
You can get the current user’s id with getuid().
Presumably the reason there’s no single-call way of getting the information you want is that it’s uncommon for a program to care whether the user owns a file; OS X, like UNIX in general, is more about permissions than ownership, so usually you’d use calls like isWritableFileAtPath: or isDeletableFileAtPath: