Changeset 2146


Ignore:
Timestamp:
Jun 18, 2007, 2:46:22 AM (15 years ago)
Author:
livings124
Message:

don't allow torrent files to be created if a file with the same name and directory already exists

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/file_selection/macosx/CreatorWindowController.m

    r2145 r2146  
    156156- (void) create: (id) sender
    157157{
    158     #warning check already exists
    159    
    160158    //parse tracker string
    161159    NSString * trackerString = [fTrackerField stringValue];
     
    188186        [alert setInformativeText: NSLocalizedString(@"Change the tracker address to create the torrent.",
    189187                                                    "Create torrent -> no url warning -> warning")];
     188        [alert setAlertStyle: NSWarningAlertStyle];
     189       
     190        [alert beginSheetModalForWindow: [self window] modalDelegate: self didEndSelector: nil contextInfo: nil];
     191        return;
     192    }
     193   
     194    //check if a file with the same name and location already exists
     195    if ([[NSFileManager defaultManager] fileExistsAtPath: fLocation])
     196    {
     197        NSArray * pathComponents = [fLocation pathComponents];
     198        int count = [pathComponents count];
     199       
     200        NSAlert * alert = [[[NSAlert alloc] init] autorelease];
     201        [alert addButtonWithTitle: NSLocalizedString(@"OK", "Create torrent -> file already exists warning -> button")];
     202        [alert setMessageText: NSLocalizedString(@"A torrent file with this name and directory cannot be created.",
     203                                                "Create torrent -> file already exists warning -> title")];
     204        [alert setInformativeText: [NSString stringWithFormat:
     205                NSLocalizedString(@"A file with the name \"%@\" already exists in the directory \"%@\". "
     206                    "Choose a new name or directory to create the torrent.",
     207                    "Create torrent -> file already exists warning -> warning"),
     208                    [pathComponents objectAtIndex: count-1], [pathComponents objectAtIndex: count-2]]];
    190209        [alert setAlertStyle: NSWarningAlertStyle];
    191210       
Note: See TracChangeset for help on using the changeset viewer.