diff options
author | stuconnolly <stuart02@gmail.com> | 2010-07-05 15:46:21 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2010-07-05 15:46:21 +0000 |
commit | 2ba4d06e3fbc8f96e6b37a7d56e0889e50e7315a (patch) | |
tree | 2a5a9f13dfbdd2ed28fb223fe92f5702dab5aa35 /Source | |
parent | b1e1b34e431cb820538f60dd28d98d3e6821ebd3 (diff) | |
download | sequelpro-2ba4d06e3fbc8f96e6b37a7d56e0889e50e7315a.tar.gz sequelpro-2ba4d06e3fbc8f96e6b37a7d56e0889e50e7315a.tar.bz2 sequelpro-2ba4d06e3fbc8f96e6b37a7d56e0889e50e7315a.zip |
- Replace forward slashes with hyphens in export filenames generated from the use of custom tokens to accommodate dates which include them.
- Ensure that the displayed custom export filename includes the default extension.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPExportController.m | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/Source/SPExportController.m b/Source/SPExportController.m index aac8592b..a4851f53 100644 --- a/Source/SPExportController.m +++ b/Source/SPExportController.m @@ -39,6 +39,7 @@ - (void)_updateDisplayedExportFilename; - (NSString *)_generateDefaultExportFilename; +- (NSString *)_currentDefaultExportFileExtension; - (void)_toggleExportButton:(id)uiStateDict; - (void)_toggleExportButtonOnBackgroundThread; @@ -260,12 +261,20 @@ range:NSMakeRange(0, [string length])]; // Strip comma separators - [string replaceOccurrencesOfString:@"," withString:@"" + [string replaceOccurrencesOfString:@"," + withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [string length])]; // Replace colons with hyphens - [string replaceOccurrencesOfString:@":" withString:@"-" + [string replaceOccurrencesOfString:@":" + withString:@"-" + options:NSLiteralSearch + range:NSMakeRange(0, [string length])]; + + // Replace forward slashes with hyphens + [string replaceOccurrencesOfString:@"/" + withString:@"-" options:NSLiteralSearch range:NSMakeRange(0, [string length])]; @@ -690,7 +699,18 @@ */ - (void)_updateDisplayedExportFilename { - NSString *filename = ([[exportCustomFilenameTokenField stringValue] length] > 0) ? [self expandCustomFilenameFormatFromString:[exportCustomFilenameTokenField stringValue] usingTableName:[[tablesListInstance tables] objectAtIndex:1]] : [self _generateDefaultExportFilename]; + NSString *filename = @""; + + if ([[exportCustomFilenameTokenField stringValue] length] > 0) { + + // Get the current export file extension + NSString *extension = [self _currentDefaultExportFileExtension]; + + filename = [[self expandCustomFilenameFormatFromString:[exportCustomFilenameTokenField stringValue] usingTableName:[[tablesListInstance tables] objectAtIndex:1]] stringByAppendingPathExtension:extension]; + } + else { + filename = [self _generateDefaultExportFilename]; + } [exportCustomFilenameViewLabelButton setTitle:[NSString stringWithFormat:NSLocalizedString(@"Customize Filename (%@)", @"customize file name label"), filename]]; } @@ -701,7 +721,7 @@ - (NSString *)_generateDefaultExportFilename { NSString *filename = @""; - NSString *extension = @""; + NSString *extension = [self _currentDefaultExportFileExtension]; // Determine what the file name should be switch (exportSource) @@ -717,6 +737,16 @@ break; } + return ([extension length] > 0) ? [filename stringByAppendingPathExtension:extension] : filename; +} + +/** + * Returns the current default export file extension based on the selected export type. + */ +- (NSString *)_currentDefaultExportFileExtension +{ + NSString *extension = @""; + switch (exportType) { case SPSQLExport: extension = ([exportCompressOutputFile state]) ? [NSString stringWithFormat:@"%@.gz", SPFileExtensionSQL] : SPFileExtensionSQL; @@ -729,7 +759,7 @@ break; } - return ([extension length] > 0) ? [filename stringByAppendingPathExtension:extension] : filename; + return extension; } /** |