Commit af404258 authored by Felix Paul Kühne's avatar Felix Paul Kühne

* don't overwrite existing files

parent 0ffd9814
......@@ -102,7 +102,6 @@
"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;
......
......@@ -17,6 +17,6 @@
<integer>6</integer>
</array>
<key>IBSystem Version</key>
<string>8G32</string>
<string>8H14</string>
</dict>
</plist>
......@@ -110,7 +110,6 @@
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;
......
......@@ -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"];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment