Re: [ NSKeyedArchiver ] archiveRootObject:toFile: hoses my directory's permissions
Re: [ NSKeyedArchiver ] archiveRootObject:toFile: hoses my directory's permissions
- Subject: Re: [ NSKeyedArchiver ] archiveRootObject:toFile: hoses my directory's permissions
- From: Erg Consultant <email@hidden>
- Date: Sat, 30 May 2009 15:15:17 -0700 (PDT)
- (void)flushRegistry
{
BOOL flushed = NO;
NSString *registryFileFullPath = nil;
mypathUtils *pathUtils = nil;
if( gReg )
{
// Make path utils...
pathUtils = [ [ mypathUtils alloc ] init ];
if( pathUtils )
{
// Get the Registry file's full path...
registryFileFullPath = [ pathUtils registryFileFullPath ];
if( registryFileFullPath )
{
// Reset the flush time to now...
if( lastFlushTime )
{
[ lastFlushTime release ];
}
lastFlushTime = [ [ NSDate alloc ] init ];
if( lastFlushTime )
{
// Create or write the object graph to the archive...
flushed = [ NSKeyedArchiver archiveRootObject:self toFile:registryFileFullPath ];
// Make the archive Finder-invisible to make it harder to find.
[ registryFileFullPath makeItemVisible:NO ];
}
}
// Clean up...
[ pathUtils release ];
}
}
}
________________________________
From: Jim Correia <email@hidden>
To: email@hidden
Sent: Saturday, May 30, 2009 6:06:05 AM
Subject: Re: [ NS KeyedArchiver ] archiveRootObject:toFile: hoses my directory's permissions
On Sat, May 30, 2009 at 1:39 AM, Erg Consultant <email@hidden>
wrote:
> Why does archiveRootObject:toFile: change the permissions on the parent
> directory? I didn't ask it to. This dir has to be writable for all users -
> the way I installed it - not by only the current user.
>
> How can I avoid having the permissions changed?
Show your code. In a trivial sample app here, this is not the behavior
I observe.
- JIm
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *outputFilePath =
[@"~/Desktop/output-parent/outputfile.keyedArchive"
stringByExpandingTildeInPath];
NSString *outputDir = [outputFilePath stringByDeletingLastPathComponent];
NSDictionary *attributes = [NSDictionary dictionaryWithObject:
[NSNumber numberWithUnsignedInt: 0777] forKey:
NSFilePosixPermissions];
BOOL success = NO;
success = [[NSFileManager defaultManager] createDirectoryAtPath:
outputDir attributes: attributes];
success = [NSKeyedArchiver archiveRootObject: @"my object" toFile:
outputFilePath];
attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:
outputDir error: NULL];
NSLog(@"permissions = %o", [[attributes objectForKey:
NSFilePosixPermissions] unsignedIntValue]);
[pool drain];
return 0;
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden