diff options
author | dynaflash <[email protected]> | 2008-12-12 17:31:16 +0000 |
---|---|---|
committer | dynaflash <[email protected]> | 2008-12-12 17:31:16 +0000 |
commit | cec83b5d831f2c988e5544ddc16602bda903a225 (patch) | |
tree | aef778c703a25fae7a27b11bcb4b2cdee0ea1395 /macosx | |
parent | 1a295f78e540e2c086e07615efeaf1c3268637eb (diff) |
MacGui: Add to queue fix so that it not only checks that a file does not already exist at the destination path, but also check through the existing queue items and warn of an overwrite.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2022 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/Controller.mm | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/macosx/Controller.mm b/macosx/Controller.mm index 24acbbb06..0bf28c766 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -3221,18 +3221,51 @@ fWorkingCount = 0; NSRunAlertPanel(@"Warning!", @"This is not a valid destination directory!", @"OK", nil, nil); return; } - - /* We check for duplicate name here */ - if( [[NSFileManager defaultManager] fileExistsAtPath: - [fDstFile2Field stringValue]] ) + + BOOL fileExists; + fileExists = NO; + + BOOL fileExistsInQueue; + fileExistsInQueue = NO; + + /* We check for and existing file here */ + if([[NSFileManager defaultManager] fileExistsAtPath: [fDstFile2Field stringValue]]) { - NSBeginCriticalAlertSheet( NSLocalizedString( @"File already exists", @"" ), - NSLocalizedString( @"Cancel", @"" ), NSLocalizedString( @"Overwrite", @"" ), nil, fWindow, self, - @selector( overwriteAddToQueueAlertDone:returnCode:contextInfo: ), - NULL, NULL, [NSString stringWithFormat: - NSLocalizedString( @"Do you want to overwrite %@?", @"" ), - [fDstFile2Field stringValue]] ); - // overwriteAddToQueueAlertDone: will be called when the alert is dismissed. + fileExists = YES; + } + + /* We now run through the queue and make sure we are not overwriting an exisiting queue item */ + int i = 0; + NSEnumerator *enumerator = [QueueFileArray objectEnumerator]; + id tempObject; + while (tempObject = [enumerator nextObject]) + { + NSDictionary *thisQueueDict = tempObject; + if ([[thisQueueDict objectForKey:@"DestinationPath"] isEqualToString: [fDstFile2Field stringValue]]) + { + fileExistsInQueue = YES; + } + i++; + } + + + if(fileExists == YES) + { + NSBeginCriticalAlertSheet( NSLocalizedString( @"File already exists.", @"" ), + NSLocalizedString( @"Cancel", @"" ), NSLocalizedString( @"Overwrite", @"" ), nil, fWindow, self, + @selector( overwriteAddToQueueAlertDone:returnCode:contextInfo: ), + NULL, NULL, [NSString stringWithFormat: + NSLocalizedString( @"Do you want to overwrite %@?", @"" ), + [fDstFile2Field stringValue]] ); + } + else if (fileExistsInQueue == YES) + { + NSBeginCriticalAlertSheet( NSLocalizedString( @"There is already a queue item for this destination.", @"" ), + NSLocalizedString( @"Cancel", @"" ), NSLocalizedString( @"Overwrite", @"" ), nil, fWindow, self, + @selector( overwriteAddToQueueAlertDone:returnCode:contextInfo: ), + NULL, NULL, [NSString stringWithFormat: + NSLocalizedString( @"Do you want to overwrite %@?", @"" ), + [fDstFile2Field stringValue]] ); } else { |