Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

cea

macrumors newbie
Original poster
Oct 26, 2009
22
0
Hi,
I just did a test to change file permissions. It works but it does not pop up the Authentication dialog.
Is there something wrong?
Thank you:

PHP:
#import "untitled.h"

@implementation untitled
- (IBAction)myAction:(id)sender
{
	NSFileManager *fileManager = [NSFileManager defaultManager];
	NSString *path = @"/Users/cea/Desktop/test.zip";
	
	// Set permissions to prohibit access from other users
	NSDictionary *attr=[NSDictionary dictionaryWithObject:[NSNumber numberWithUnsignedLong:0777U] forKey:NSFilePosixPermissions];
	[fileManager setAttributes:attr ofItemAtPath:path error:nil];
	NSLog(@"0777 %@", path);
}

@end
 
First, if you own a file or folder, then you always have the ability to change its permissions. No authentication dialog is needed.

Second, changing the permissions to 0777 (octal) does not prohibit access by others. Quite the opposite: it grants read and write access to everyone. Anyone can read or write to the file. It also marks the file as executable, which is simply wrong for a zip file.

Why do you think 0777 will prohibit access from others? Please give the full name or URL of the reference or book you're reading this from.
 
ohh the comment belongs to another test code which was here before. i just forgot to remove it.
Thank you for your info!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.