Changeset 4277

Show
Ignore:
Timestamp:
06/09/06 19:38:09 (2 years ago)
Author:
morris
Message:

Synchronize accounts writing with config writing

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • WiredServer/trunk/PreferencePane/English.lproj/Localizable.strings

    r4276 r4277  
    11/* File comment (application, date) */ 
    22"# This file was generated by %@ at %@" = "# This file was generated by %1$@ at %2$@"; 
    3  
    4 /* File comment */ 
    5 "# This file was generated by %@ at %@\n" = "# This file was generated by %1$@ at %2$@\n"; 
    63 
    74/* Certificate */ 
  • WiredServer/trunk/WCAccounts.m

    r4251 r4277  
    561561 
    562562- (BOOL)writeToFile:(NSString *)file { 
    563         NSEnumerator    *enumerator; 
    564         NSFileHandle    *fileHandle; 
    565         NSString                *comment, *line; 
    566         WCAccount               *account; 
     563        NSEnumerator            *enumerator; 
     564        NSMutableString         *string; 
     565        WCAccount                       *account; 
    567566         
    568567        if(![[NSFileManager defaultManager] fileExistsAtPath:file]) { 
     
    571570                                                                                          attributes:NULL]; 
    572571        } 
    573  
    574         fileHandle = [NSFileHandle fileHandleForWritingAtPath:file]; 
    575          
    576         if(!fileHandle) 
    577                 return NO; 
    578          
    579         comment = [NSSWF: 
    580                 WCLS(@"# This file was generated by %@ at %@\n", @"File comment"), 
    581                 [[NSBundle bundleForClass:[self class]] objectForInfoDictionaryKey:@"CFBundleExecutable"], 
     572         
     573        string = [NSMutableString string]; 
     574        [string appendFormat:WCLS(@"# This file was generated by %@ at %@", @"File comment (application, date)"), 
     575                [[self bundle] objectForInfoDictionaryKey:@"CFBundleExecutable"], 
    582576                [[NSDate date] fullDateStringWithSeconds:YES]]; 
    583         [fileHandle writeData:[comment dataUsingEncoding:NSUTF8StringEncoding]]; 
     577        [string appendString:@"\n"]; 
    584578         
    585579        enumerator = [[_accounts sortedArrayUsingSelector:@selector(compareName:)] objectEnumerator]; 
    586580         
    587         while((account = [enumerator nextObject])) { 
    588                 line = [NSSWF:@"%@\n", [account description]]; 
    589                 [fileHandle writeData:[line dataUsingEncoding:NSUTF8StringEncoding]]; 
    590         } 
    591          
    592         [fileHandle closeFile]; 
    593          
    594         return YES; 
     581        while((account = [enumerator nextObject])) 
     582                [string appendFormat:@"%@\n", [account description]]; 
     583         
     584        return [[string dataUsingEncoding:NSUTF8StringEncoding] writeToFile:file atomically:YES]; 
    595585} 
    596586