- (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 <jim.corr...@pobox.com>
To: cocoa-dev@lists.apple.com
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 <erg_consult...@yahoo.com>
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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/erg_consultant%40yahoo.com

This email sent to erg_consult...@yahoo.com



      
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to