I want to create a file at /Libary/Logs in my Mac application.
I am using the following code,
NSError *error = nil;
NSFileManager *fm = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSLocalDomainMask, YES);
NSString *path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Logs"];
//path = [path stringByAppendingPathComponent:@"e315Updater"];
if ( ![fm fileExistsAtPath:path] )
{
BOOL sucess = [fm createDirectoryAtPath:path
withIntermediateDirectories:YES
attributes:nil
error:&error];
NSLog(@"Success value = %d",sucess);
if ( error ){
NSLog(@"Err = %@",[error description]);
}
}
It keeps failing because of the permissions issue as every user does NOT have read/write permissions to this directory.
I also tried to set permissions on /Libary/Logs directory by using NSFilePosixPermissions but it failes to set the Read/write permissions also.
So I need help in figuring out that 'How to create and read/write to file inside Library/Logs of main Disk not the users Library'