+ /* 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];
+ int x = 0;
+ int y = [[o_userSelections objectForKey:@"pathToStrm"] count];
+ NSMutableString * tempString = [[NSMutableString alloc] init];
+ while( x != y )
+ {
+ NSString * fileNameToUse;
+ /* check whether the extension is hidden or not.
+ * if not, remove it
+ * we need the casting to make GCC4 happy */
+ if( [[[NSFileManager defaultManager] fileAttributesAtPath:
+ [[o_userSelections objectForKey:@"pathToStrm"]
+ objectAtIndex: x] traverseLink: NO] objectForKey:
+ NSFileExtensionHidden] )
+ fileNameToUse = [NSString stringWithString:
+ [[NSFileManager defaultManager] displayNameAtPath:
+ [[o_userSelections objectForKey:@"pathToStrm"]
+ objectAtIndex: x]]];
+ else
+ {
+ int z = 0;
+ int count = [[[[NSFileManager defaultManager]
+ displayNameAtPath:
+ [[o_userSelections objectForKey:@"pathToStrm"]
+ objectAtIndex: x]]
+ componentsSeparatedByString: @"."] count];
+ fileNameToUse = @"";
+ while( z < (count - 1) )
+ {
+ fileNameToUse = [fileNameToUse stringByAppendingString:
+ [[[[NSFileManager defaultManager]
+ displayNameAtPath:
+ [[o_userSelections objectForKey:@"pathToStrm"]
+ objectAtIndex: x]]
+ componentsSeparatedByString: @"."]
+ objectAtIndex: z]];
+ z += 1;
+ }
+ }
+ tempString = [NSString stringWithFormat: @"%@%@.%@",
+ [o_t7_fld_filePath stringValue],
+ fileNameToUse, theEncapFormat];
+ if( [[NSFileManager defaultManager] fileExistsAtPath:
+ tempString] )
+ {
+ /* we don't wanna overwrite existing files, so add an
+ * int to the file-name */
+ int additionalInt = 1;
+ while( additionalInt < 100 )
+ {
+ tempString = [NSString stringWithFormat:@"%@%@ %i.%@",
+ [o_t7_fld_filePath stringValue],
+ fileNameToUse, additionalInt, theEncapFormat];
+ if(! [[NSFileManager defaultManager]
+ fileExistsAtPath: tempString] )
+ break;
+ additionalInt += 1;
+ }
+ if( additionalInt >= 100 )
+ msg_Err( VLCIntf, "Files with the same name are "
+ "already present in the destination directory. "
+ "Delete these files or choose a different directory." );
+ }
+ [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"];
+ }