aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPAppController.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-11-09 19:41:24 +0000
committerBibiko <bibiko@eva.mpg.de>2010-11-09 19:41:24 +0000
commit0a5acd7a34f5e759171a82b0e4995b25d815d5cf (patch)
tree2362f6199cf3b04d9bec4001b6be74d6302448a5 /Source/SPAppController.m
parentf39a7b24b21baccaeed950e9a854cab45ceb4c80 (diff)
downloadsequelpro-0a5acd7a34f5e759171a82b0e4995b25d815d5cf.tar.gz
sequelpro-0a5acd7a34f5e759171a82b0e4995b25d815d5cf.tar.bz2
sequelpro-0a5acd7a34f5e759171a82b0e4995b25d815d5cf.zip
• further preparations for user-definable bundle support
Diffstat (limited to 'Source/SPAppController.m')
-rw-r--r--Source/SPAppController.m32
1 files changed, 31 insertions, 1 deletions
diff --git a/Source/SPAppController.m b/Source/SPAppController.m
index 97ea3ba8..34ff1dda 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -461,7 +461,37 @@
}
}
else if([[[filename pathExtension] lowercaseString] isEqualToString:[SPUserBundleFileExtension lowercaseString]]) {
- NSLog(@"Be patient…");
+
+ NSFileManager *fm = [NSFileManager defaultManager];
+
+ NSString *bundlePath = [[NSFileManager defaultManager] applicationSupportDirectoryForSubDirectory:SPBundleSupportFolder error:nil];
+
+ if(!bundlePath) return;
+
+ if(![fm fileExistsAtPath:bundlePath isDirectory:nil]) {
+ if(![fm createDirectoryAtPath:bundlePath withIntermediateDirectories:YES attributes:nil error:nil]) {
+ NSBeep();
+ return;
+ }
+ }
+
+ NSString *newPath = [NSString stringWithFormat:@"%@/%@", bundlePath, [filename lastPathComponent]];
+ if(![fm fileExistsAtPath:newPath isDirectory:nil]) {
+ if(![fm copyItemAtPath:filename toPath:newPath error:nil]) {
+ NSBeep();
+ return;
+ }
+ } else {
+ NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Error while installing bundle file", @"error while installing bundle file")]
+ defaultButton:NSLocalizedString(@"OK", @"OK button")
+ alternateButton:nil
+ otherButton:nil
+ informativeTextWithFormat:[NSString stringWithFormat:NSLocalizedString(@"The bundle ‘%@’ already exists.", @"the bundle ‘%@’ already exists."), [filename lastPathComponent]]];
+
+ [alert setAlertStyle:NSCriticalAlertStyle];
+ [alert runModal];
+ return;
+ }
}
else {
NSLog(@"Only files with the extensions ‘%@’, ‘%@’, ‘%@’ or ‘%@’ are allowed.", SPFileExtensionDefault, SPBundleFileExtension, SPColorThemeFileExtension, SPFileExtensionSQL);