Browse Source

Show alert if opening the config file on OS X files, which can happen when the app is launched from the read-only disk imager

Kevin Wojniak 9 years ago
parent
commit
08b6fc7d9b
1 changed files with 8 additions and 3 deletions
  1. 8 3
      src/main.c

+ 8 - 3
src/main.c

@@ -2511,9 +2511,14 @@ main(int argc, char *argv[])
 - (void)editConfig
 - (void)editConfig
 {
 {
 	create_config_file(g_ctx, g_config_file_name);
 	create_config_file(g_ctx, g_config_file_name);
-	[[NSWorkspace sharedWorkspace]
-	           openFile:[NSString stringWithUTF8String:g_config_file_name]
-	    withApplication:@"TextEdit"];
+	NSString *path = [NSString stringWithUTF8String:g_config_file_name];
+	if (![[NSWorkspace sharedWorkspace] openFile:path withApplication:@"TextEdit"]) {
+			NSAlert *alert = [[[NSAlert alloc] init] autorelease];
+			[alert setAlertStyle:NSWarningAlertStyle];
+			[alert setMessageText:NSLocalizedString(@"Unable to open config file.", "")];
+			[alert setInformativeText:path];
+			(void)[alert runModal];
+	}
 }
 }
 - (void)shutDown
 - (void)shutDown
 {
 {