]> git.sesse.net Git - vlc/commitdiff
* don't overwrite existing files
authorFelix Paul Kühne <fkuehne@videolan.org>
Fri, 17 Mar 2006 20:07:25 +0000 (20:07 +0000)
committerFelix Paul Kühne <fkuehne@videolan.org>
Fri, 17 Mar 2006 20:07:25 +0000 (20:07 +0000)
extras/MacOSX/Resources/English.lproj/Wizard.nib/classes.nib
extras/MacOSX/Resources/English.lproj/Wizard.nib/info.nib
extras/MacOSX/Resources/English.lproj/Wizard.nib/keyedobjects.nib
modules/gui/macosx/wizard.h
modules/gui/macosx/wizard.m

index b79b58a0b70f56bcb2554c4d28a14b3c8d74bc42..684eb98dad08a3c580c8360fdc22ed4e4919e1f0 100644 (file)
                 "o_t7_fld_filePath" = id; 
                 "o_t7_text" = id; 
                 "o_t7_title" = id; 
-                "o_t7_txt_note_saveFolderTo" = id; 
                 "o_t7_txt_saveFileTo" = id; 
                 "o_t8_fld_destination" = id; 
                 "o_t8_fld_encapFormat" = id; 
index f08eebdaa5f53c9e995d03c4ab02118167fbac70..e6df3fa31d31db944f5fb6a9fb018013e2db1495 100644 (file)
@@ -17,6 +17,6 @@
                <integer>6</integer>
        </array>
        <key>IBSystem Version</key>
-       <string>8G32</string>
+       <string>8H14</string>
 </dict>
 </plist>
index fc043378fb3eaf638f7490feb50960f31957708a..ebf697c949f06a4e5b237529ee5830da9debe13f 100644 (file)
Binary files a/extras/MacOSX/Resources/English.lproj/Wizard.nib/keyedobjects.nib and b/extras/MacOSX/Resources/English.lproj/Wizard.nib/keyedobjects.nib differ
index da8f62dc9a63a85a53e9e20fc12f28591afc23d8..55b1656ee7526a3421a06e28df7b928a835a3f0b 100644 (file)
     IBOutlet id o_t7_text;
     IBOutlet id o_t7_title;
     IBOutlet id o_t7_txt_saveFileTo;
-    IBOutlet id o_t7_txt_note_saveFolderTo;
     IBOutlet id o_t7_btn_mrInfo_local;
     IBOutlet id o_t7_ckb_local;
     
index d2fc39ec1bb29bcf3af32846fdc4649f1255bd45..d3c3f9dc68de3437ad70c18fcf06281cbdd3654e 100644 (file)
@@ -453,9 +453,6 @@ static VLCWizard *_o_sharedInstance = nil;
     [o_t7_btn_chooseFile setTitle: _NS("Choose...")];
     [o_t7_ckb_local setTitle: _NS("Local playback")];
     [o_t7_btn_mrInfo_local setTitle: _NS("More Info")];
-    [o_t7_txt_note_saveFolderTo setStringValue: _NS("Note that your input " \
-        "files will keep their original names when being saved in the folder " \
-        "you selected. Existing files may be overwritten.")];
 
     /* page eight ("Summary") */
     [o_t8_txt_text setStringValue: _NS("This page lists all your selections. " \
@@ -1117,13 +1114,11 @@ static VLCWizard *_o_sharedInstance = nil;
             {
                 [o_t7_txt_saveFileTo setStringValue: 
                     _NS("Select the folder to save to")];
-                [o_t7_txt_note_saveFolderTo setHidden: NO];
             }
             else
             {
                 [o_t7_txt_saveFileTo setStringValue: 
                     _NS("Select the file to save to")];
-                [o_t7_txt_note_saveFolderTo setHidden: YES];
             }
         }
     }
@@ -1183,31 +1178,65 @@ static VLCWizard *_o_sharedInstance = nil;
                     _NS("Enter either a valid path or choose a location " \
                     "through the button's dialog-box.")]);
         } else {
+            /* create a string containing the requested suffix for later usage */
+            NSString * theEncapFormat = [[o_encapFormats objectAtIndex: \
+                [[o_userSelections objectForKey:@"encapFormat"] intValue]] \
+                objectAtIndex:0];
+            if( theEncapFormat == @"ps" )
+                theEncapFormat = @"mpg";
+
+            /* look whether we need to process multiple items or not.
+             * choose a faster variant if we just want a single item */
             if( [[o_userSelections objectForKey:@"pathToStrm"] count] > 1 )
             {
                 NSMutableArray * tempArray = [[NSMutableArray alloc] init];
-                NSString * theEncapFormat = [[o_encapFormats objectAtIndex: \
-                    [[o_userSelections objectForKey:@"encapFormat"] intValue]] \
-                    objectAtIndex:0];
-                if( theEncapFormat == @"ps" )
-                    theEncapFormat = @"mpg";
                 int x = 0;
                 int y = [[o_userSelections objectForKey:@"pathToStrm"] count];
+                NSMutableString * tempString = [[NSMutableString alloc] init];
                 while( x != y )
                 {
-                    [tempArray addObject:[NSString stringWithFormat: @"%@%@.%@",
+                    tempString = [NSString stringWithFormat: @"%@%@.%@",
                         [o_t7_fld_filePath stringValue],
                         [[NSFileManager defaultManager] displayNameAtPath:
                         [[o_userSelections objectForKey:@"pathToStrm"]
-                        objectAtIndex: x]],theEncapFormat]];
+                        objectAtIndex: x]],theEncapFormat];
+                    if( [[NSFileManager defaultManager] fileExistsAtPath: \
+                        tempString] )
+                    {
+                        /* we don't wanna overwrite existing files, so add an
+                         * int to the file-name */
+                        int additionalInt = 0;
+                        while( additionalInt < 100 )
+                        {
+                            tempString = [NSString stringWithFormat:@"%@%@.%i.%@",
+                                [o_t7_fld_filePath stringValue],
+                                [[NSFileManager defaultManager] displayNameAtPath:
+                                [[o_userSelections objectForKey:@"pathToStrm"]
+                                objectAtIndex: x]], additionalInt,
+                                theEncapFormat];
+                            if(! [[NSFileManager defaultManager] \
+                                fileExistsAtPath: tempString] )
+                                break;
+                            additionalInt += 1;
+                        }
+                        if( additionalInt >= 100 )
+                            msg_Err( VLCIntf, "your destination folder is " \
+                                "cluttered with files with the same name. " \
+                                "clean up a bit and try again." );
+                    }
+                    [tempArray addObject: [tempString retain]];
                     x += 1;
                 }
                 [o_userSelections setObject: [NSArray arrayWithArray:tempArray]
                     forKey: @"trnscdFilePath"];
                 [tempArray release];
+                [tempString release];
             }
             else
             {
+                /* we don't need to check for existing items because Cocoa
+                 * does that already when we are asking the user for a location
+                 * to save her file */
                 [o_userSelections setObject: [NSArray arrayWithObject: \
                     [o_t7_fld_filePath stringValue]] forKey: @"trnscdFilePath"];
             }