diff options
author | stuconnolly <stuart02@gmail.com> | 2010-11-04 19:58:25 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2010-11-04 19:58:25 +0000 |
commit | ef08e45c0fa1a5e562194ef63c6ab1a441d017a3 (patch) | |
tree | 96ee19255ac4b71558dd9da0d08bb12594103799 /Source | |
parent | 55183c8fd5bc6d0c84d38255a4b0fafd42f6cbbe (diff) | |
download | sequelpro-ef08e45c0fa1a5e562194ef63c6ab1a441d017a3.tar.gz sequelpro-ef08e45c0fa1a5e562194ef63c6ab1a441d017a3.tar.bz2 sequelpro-ef08e45c0fa1a5e562194ef63c6ab1a441d017a3.zip |
Fix a few issues that prevented an XML export to multiple files.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPExportInitializer.m | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/Source/SPExportInitializer.m b/Source/SPExportInitializer.m index bcf678b4..7b1b9451 100644 --- a/Source/SPExportInitializer.m +++ b/Source/SPExportInitializer.m @@ -318,9 +318,13 @@ // If required create a single file handle for all XML exports if (![self exportToMultipleFiles]) { - [singleExportFile setExportFileNeedsXMLHeader:YES]; - - [exportFiles addObject:singleExportFile]; + if (!singleFileHandleSet) { + [singleExportFile setExportFileNeedsXMLHeader:YES]; + + [exportFiles addObject:singleExportFile]; + + singleFileHandleSet = YES; + } [xmlExporter setExportOutputFile:singleExportFile]; } @@ -394,10 +398,10 @@ } NSMutableArray *problemFiles = [[NSMutableArray alloc] init]; - + // Create the actual file handles while dealing with errors (e.g. file already exists, etc) during creation for (SPExportFile *exportFile in exportFiles) - { + { if ([exportFile createExportFileHandle:NO] == SPExportFileHandleCreated) { [exportFile setCompressionFormat:[exportOutputCompressionFormatPopupButton indexOfSelectedItem]]; @@ -491,26 +495,38 @@ { SPXMLExporter *xmlExporter = [[SPXMLExporter alloc] initWithDelegate:self]; - // Depeding on the export source, set the table name or data array - if (exportSource == SPTableExport) { - [xmlExporter setXmlTableName:table]; - } - else { + // if required set the data array + if (exportSource != SPTableExport) { [xmlExporter setXmlDataArray:dataArray]; } // Regardless of the export source, set exporter's table name as it's used in the output // of table and table content exports. - [xmlExporter setXmlTableName:[tablesListInstance tableName]]; + [xmlExporter setXmlTableName:table]; [xmlExporter setXmlNULLString:[exportXMLNULLValuesAsTextField stringValue]]; // If required create separate files if ((exportSource == SPTableExport) && exportToMultipleFiles && (exportTableCount > 0)) { - [exportFilename setString:[[exportPathField stringValue] stringByAppendingPathComponent:table]]; + + if (createCustomFilename) { + + // Create custom filename based on the selected format + [exportFilename setString:[self expandCustomFilenameFormatFromString:[exportCustomFilenameTokenField stringValue] usingTableName:table]]; + + // If the user chose to use a custom filename format and we exporting to multiple files, make + // sure the table name is included to ensure the output files are unique. + if (exportTableCount > 1) { + [exportFilename setString:([[exportCustomFilenameTokenField stringValue] rangeOfString:@"table" options:NSLiteralSearch].location == NSNotFound) ? [exportFilename stringByAppendingFormat:@"_%@", table] : exportFilename]; + } + } + else { + [exportFilename setString:(dataArray) ? [tableDocumentInstance database] : table]; + } + [exportFilename setString:[exportFilename stringByAppendingPathExtension:[self currentDefaultExportFileExtension]]]; - - SPExportFile *file = [SPExportFile exportFileAtPath:exportFilename]; + + SPExportFile *file = [SPExportFile exportFileAtPath:[[exportPathField stringValue] stringByAppendingPathComponent:exportFilename]]; [file setExportFileNeedsXMLHeader:YES]; |