summaryrefslogtreecommitdiffstats
path: root/macosx/Controller.mm
diff options
context:
space:
mode:
authordynaflash <[email protected]>2008-12-12 17:31:16 +0000
committerdynaflash <[email protected]>2008-12-12 17:31:16 +0000
commitcec83b5d831f2c988e5544ddc16602bda903a225 (patch)
treeaef778c703a25fae7a27b11bcb4b2cdee0ea1395 /macosx/Controller.mm
parent1a295f78e540e2c086e07615efeaf1c3268637eb (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/Controller.mm')
-rw-r--r--macosx/Controller.mm55
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
{