Changeset 4871

Show
Ignore:
Timestamp:
08/22/07 14:33:02 (11 months ago)
Author:
morris
Message:

Do the file write immediately when we've gotten the data

Ask user to overwrite if file exists at path

Files:

Legend:

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

    r4870 r4871  
    2626"Actual Size" = "Actual Size"; 
    2727 
    28 /* Move to trash dialog button title */ 
     28/* Move to trash dialog button title 
     29   File exists dialog button title */ 
    2930"Cancel" = "Cancel"; 
    3031 
    3132/* Move to trash dialog message */ 
    32 "Could not move to trash" = "Could not move to trash"; 
     33"Could Not Move To Trash" = "Could Not Move To Trash"; 
    3334 
    3435/* Move to trash dialog button title */ 
     
    3738/* Move to trash dialog description */ 
    3839"Do you want to delete \"%@\" immediately?" = "Do you want to delete “%@” immediately?"; 
     40 
     41/* File exists dialog title */ 
     42"File Exists" = "File Exists"; 
    3943 
    4044/* Menu item title */ 
     
    5559/* Move to trash toolbar item */ 
    5660"Move To Trash" = "Move To Trash"; 
     61 
     62/* File exists dialog button title */ 
     63"Overwrite" = "Overwrite"; 
     64 
     65/* File exists dialog button title */ 
     66"Overwrite All" = "Overwrite All"; 
    5767 
    5868/* Parent toolbar item */ 
     
    8999"Stretch To Fit" = "Stretch To Fit"; 
    90100 
     101/* File exists dialog description */ 
     102"The file \"%@\" already exists. Overwrite?" = "The file “%@” already exists. Overwrite?"; 
     103 
    91104/* Zoom to fit toolbar item */ 
    92105"Zoom To Fit" = "Zoom To Fit"; 
  • Footagehead/trunk/FHBrowserController.h

    r4868 r4871  
    7373        BOOL                                                    _switchingURL; 
    7474        NSInteger                                               _previousRow; 
     75 
     76        NSString                                                *_savedPath; 
    7577        NSUInteger                                              _savedFiles; 
     78        BOOL                                                    _overwriteAllExisting; 
    7679} 
    7780 
  • Footagehead/trunk/FHBrowserController.m

    r4868 r4871  
    447447        [[_imageLoader notificationCenter] 
    448448                addObserver:self 
     449                   selector:@selector(imageLoaderDidLoadFile:) 
     450                           name:FHImageLoaderDidLoadFile]; 
     451         
     452        [[_imageLoader notificationCenter] 
     453                addObserver:self 
    449454                   selector:@selector(imageLoaderDidLoadAllFiles:) 
    450455                           name:FHImageLoaderDidLoadAllFiles]; 
     
    463468         
    464469        [_imageLoader stopLoadingImagesAndThumbnails]; 
     470        [_imageLoader stopLoadingData]; 
    465471         
    466472        [_toolbarItems release]; 
     473 
     474        [_savedPath release]; 
    467475         
    468476        [super dealloc]; 
     
    647655- (void)imageLoaderDidLoadThumbnail:(NSNotification *)notification { 
    648656        [_tableView reloadData]; 
     657} 
     658 
     659 
     660 
     661- (void)imageLoaderDidLoadFile:(NSNotification *)notification { 
     662        NSAlert                 *alert; 
     663        NSString                *path; 
     664        FHFile                  *file; 
     665        int                             result; 
     666        BOOL                    write = YES; 
     667         
     668        file = [notification object]; 
     669        path = [_savedPath stringByAppendingPathComponent:[[file path] lastPathComponent]]; 
     670         
     671        if(!_overwriteAllExisting && [[NSFileManager defaultManager] fileExistsAtPath:path]) { 
     672                alert = [NSAlert alertWithMessageText:NSLS(@"File Exists", @"File exists dialog title") 
     673                                                                defaultButton:NSLS(@"Cancel", @"File exists dialog button title") 
     674                                                          alternateButton:NSLS(@"Overwrite All", @"File exists dialog button title") 
     675                                                                  otherButton:NSLS(@"Overwrite", @"File exists dialog button title") 
     676                                        informativeTextWithFormat:NSLS(@"The file \"%@\" already exists. Overwrite?", @"File exists dialog description"), [file name]]; 
     677                 
     678                result = [alert runModal]; 
     679                 
     680                if(result == NSAlertDefaultReturn) 
     681                        write = NO; 
     682                else if(result == NSAlertAlternateReturn) 
     683                        _overwriteAllExisting = YES; 
     684        } 
     685         
     686        if(write) 
     687                [[file data] writeToFile:path atomically:YES]; 
     688                 
     689        [file setData:NULL]; 
    649690} 
    650691 
     
    9701011                [_saveProgressTextField setStringValue:@""]; 
    9711012                 
     1013                [_savedPath release]; 
     1014                _savedPath = [path retain]; 
     1015 
    9721016                _savedFiles = 0; 
     1017                _overwriteAllExisting = NO; 
    9731018                 
    9741019                [NSApp beginSheet:_saveProgressPanel 
     
    9761021                        modalDelegate:self 
    9771022                   didEndSelector:@selector(saveProgressPanelDidEnd:returnCode:contextInfo:) 
    978                           contextInfo:[path retain]]; 
     1023                          contextInfo:NULL]; 
    9791024        } 
    9801025} 
     
    9831028 
    9841029- (void)saveProgressPanelDidEnd:(NSOpenPanel *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { 
    985         NSArray                 *files; 
    986         NSString                *path = contextInfo; 
    987         FHFile                  *file; 
    988         NSUInteger              i, count; 
    989          
    9901030        [_saveProgressPanel close]; 
    9911031         
    992         if(returnCode == NSAlertDefaultReturn) { 
    993                 files = [[self imageLoader] files]; 
    994                 count = [files count]; 
    995                  
    996                 for(i = 0; i < count; i++) { 
    997                         file = [files objectAtIndex:i]; 
    998                          
    999                         if([file data]) { 
    1000                                 [[file data] writeToFile:[path stringByAppendingPathComponent:[[file path] lastPathComponent]] 
    1001                                                           atomically:YES]; 
    1002                                  
    1003                                 [file setData:NULL]; 
    1004                         } 
    1005                 } 
    1006         } else { 
     1032        NSLog(@"returnCode = %d", returnCode); 
     1033         
     1034        if(returnCode != NSAlertDefaultReturn) { 
    10071035                [_imageLoader stopLoadingData]; 
    10081036        } 
     
    10101038        [_imageLoader startLoadingImages]; 
    10111039        [_imageLoader startLoadingThumbnails]; 
    1012          
    1013         [path release]; 
    10141040} 
    10151041 
     
    10501076         
    10511077        if(!result) { 
    1052                 alert = [NSAlert alertWithMessageText:NSLS(@"Could not move to trash", @"Move to trash dialog message") 
     1078                alert = [NSAlert alertWithMessageText:NSLS(@"Could Not Move To Trash", @"Move to trash dialog message") 
    10531079                                                                defaultButton:NSLS(@"Delete", @"Move to trash dialog button title") 
    10541080                                                          alternateButton:NSLS(@"Cancel", @"Move to trash dialog button title") 
  • Footagehead/trunk/FHImageLoader.m

    r4868 r4871  
    9595        } 
    9696         
    97         [_notificationCenter mainThreadPostNotificationName:FHImageLoaderDidLoadFile object:file]; 
     97        [_notificationCenter mainThreadPostNotificationName:FHImageLoaderDidLoadFile object:file waitUntilDone:YES]; 
    9898} 
    9999 
  • Footagehead/trunk/Japanese.lproj/Localizable.strings

    r4857 r4871  
    2727 
    2828/* Move to trash dialog message */ 
    29 "Could not move to trash" = "ゴミ箱に移動することはできませんでした"; 
     29"Could Not Move To Trash" = "ゴミ箱に移動することはできませんでした"; 
    3030 
    3131/* Move to trash dialog button title */