aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDataImport.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-07-24 21:34:05 +0000
committerstuconnolly <stuart02@gmail.com>2010-07-24 21:34:05 +0000
commitbf1294bd1016672aa3062bb80b546bf2f8037fb3 (patch)
tree121768027638e59af7d5830855bd19b88de7e601 /Source/SPDataImport.m
parenteb29a57a6860961c0caa00787d779f4cb4117c90 (diff)
downloadsequelpro-bf1294bd1016672aa3062bb80b546bf2f8037fb3.tar.gz
sequelpro-bf1294bd1016672aa3062bb80b546bf2f8037fb3.tar.bz2
sequelpro-bf1294bd1016672aa3062bb80b546bf2f8037fb3.zip
In addition to Gzip compression support when exporting SQL dumps add the ability to use Bzip2 compression.
Other changes include: + Enable the use of export compression (Gzip and Bzip2) for all export formats. + Move the compression options in the export dialog to the 'Advanced' export settings view. + Simplify the setting of common exporter properties (e.g. the connection, use of compression). + Fix a potential memory leak in the dot exporter. + Update the data importer to recognise Bzip2 compressed files. + Fix several display issues on export dialog. + Restore the default .csv file extension of CSV exports. + Correctly update the default export filename when selecting a output compression type. The addition of Bzip2 compression support implements issue #688.
Diffstat (limited to 'Source/SPDataImport.m')
-rw-r--r--Source/SPDataImport.m26
1 files changed, 14 insertions, 12 deletions
diff --git a/Source/SPDataImport.m b/Source/SPDataImport.m
index f78af011..b82bf1bb 100644
--- a/Source/SPDataImport.m
+++ b/Source/SPDataImport.m
@@ -596,7 +596,7 @@
- (void)importCSVFile:(NSString *)filename
{
NSAutoreleasePool *importPool;
- NSFileHandle *csvFileHandle;
+ SPFileHandle *csvFileHandle;
NSMutableData *csvDataBuffer;
const unsigned char *csvDataBufferBytes;
NSData *fileChunk;
@@ -630,7 +630,8 @@
[[SPGrowlController sharedGrowlController] setVisibilityForNotificationName:@"Import Finished"];
// Open a filehandle for the CSV file
- csvFileHandle = [NSFileHandle fileHandleForReadingAtPath:filename];
+ csvFileHandle = [SPFileHandle fileHandleForReadingAtPath:filename];
+
if (!csvFileHandle) {
SPBeginAlertSheet(NSLocalizedString(@"Import Error", @"Import Error title"),
NSLocalizedString(@"OK", @"OK button"),
@@ -1278,13 +1279,17 @@
if ( [selectedFilenames count] != 1 ) return;
pathExtension = [[[selectedFilenames objectAtIndex:0] pathExtension] uppercaseString];
- // If a file has extension ".gz", indicating gzip, fetch the next extension
- if ([pathExtension isEqualToString:@"GZ"]) {
+ // If the file has an extension '.gz' or '.bz2' indicating gzip or bzip2 compression, fetch the next extension
+ if ([pathExtension isEqualToString:@"GZ"] || [pathExtension isEqualToString:@"BZ2"]) {
NSMutableString *pathString = [NSMutableString stringWithString:[selectedFilenames objectAtIndex:0]];
- [pathString deleteCharactersInRange:NSMakeRange([pathString length]-3, 3)];
- pathExtension = [[pathString pathExtension] uppercaseString];
+
+ BOOL isGzip = [pathExtension isEqualToString:@"GZ"];
+
+ [pathString deleteCharactersInRange:NSMakeRange([pathString length] - (isGzip ? 3 : 4), (isGzip ? 3 : 4))];
+
+ pathExtension = [[pathString pathExtension] uppercaseString];
}
-
+
if ([pathExtension isEqualToString:@"SQL"]) {
[importFormatPopup selectItemWithTitle:@"SQL"];
[self changeFormat:self];
@@ -1347,7 +1352,7 @@
}
/**
- *
+ * Selectable toolbar identifiers.
*/
- (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar
{
@@ -1363,7 +1368,7 @@
}
/**
- *
+ * Displays the import error sheet with the supplied error message.
*/
- (void)showErrorSheetWithMessage:(NSString*)message
{
@@ -1381,9 +1386,6 @@
[errorsSheet makeKeyWindow];
}
-/**
- *
- */
- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
[sheet orderOut:self];