Have *nix ports automagically create a config file in the current working directory if it doesn't exist

This commit is contained in:
David Schmidt 2012-02-21 14:37:20 +00:00
parent 639b52bda2
commit a0682eeb28
3 changed files with 9 additions and 12 deletions

View File

@ -1,6 +1,6 @@
/* /*
GSport - an Apple //gs Emulator GSport - an Apple //gs Emulator
Copyright (C) 2010 - 2011 by GSport contributors Copyright (C) 2010 - 2012 by GSport contributors
Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey
@ -143,7 +143,7 @@ x_show_alert(int is_fatal, const char *str)
if(str) { if(str) {
// Provide an extra option--create a file // Provide an extra option--create a file
cfstrref2 = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, cfstrref2 = CFStringCreateWithFormat(kCFAllocatorDefault, NULL,
CFSTR("Create ~/%s"), str); CFSTR("Create ./%s"), str);
alert_param.otherText = cfstrref2; alert_param.otherText = cfstrref2;
} }
okstrref = CFSTR("Click OK to continue"); okstrref = CFSTR("Click OK to continue");
@ -201,10 +201,7 @@ x_dialog_create_gsport_conf(const char *str)
ret = x_show_alert(1, str); ret = x_show_alert(1, str);
if(ret) { if(ret) {
// Create empty file config_write_config_gsport_file();
path = "~";
snprintf(tmp_buf, 500, "touch %s/%s", path, str);
system(tmp_buf);
} }
} }

View File

@ -40,7 +40,7 @@ int g_accept_events = 0; // OG To know if the emulator is ready to accept extern
char g_argv0_path[256] = "./"; char g_argv0_path[256] = "./";
const char *g_gsport_default_paths[] = { "", "./", "${HOME}/","${CD}/", const char *g_gsport_default_paths[] = { "", "./", "${HOME}/","${CD}/","${PWD}/",
"${HOME}/Library/GSport/", "${HOME}/Library/GSport/",
"${0}/Contents/Resources/", "/usr/local/lib/", "${0}/Contents/Resources/", "/usr/local/lib/",
"/usr/local/gsport/", "/usr/local/lib/gsport/", "/usr/share/gsport/", "/usr/local/gsport/", "/usr/local/lib/gsport/", "/usr/share/gsport/",
@ -1289,8 +1289,8 @@ setup_gsport_file(char *outname, int maxlen, int ok_if_missing,
// Windows - use the current working directory // Windows - use the current working directory
gsport_expand_path(&(local_path[0]), "${CD}/config.txt", 250); gsport_expand_path(&(local_path[0]), "${CD}/config.txt", 250);
#else #else
// Non-windows - use home directory // Non-windows - use pwd to get current directory
gsport_expand_path(&(local_path[0]), "${HOME}/config.txt", 250); gsport_expand_path(&(local_path[0]), "${PWD}/config.txt", 250);
#endif #endif
strcpy(outname, &(local_path[0])); strcpy(outname, &(local_path[0]));
// Ask user if it's OK to create the file // Ask user if it's OK to create the file

View File

@ -1,6 +1,6 @@
/* /*
GSport - an Apple //gs Emulator GSport - an Apple //gs Emulator
Copyright (C) 2010 by GSport contributors Copyright (C) 2010 - 2012 by GSport contributors
Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey
@ -260,8 +260,8 @@ main(int argc, char **argv)
void void
x_dialog_create_gsport_conf(const char *str) x_dialog_create_gsport_conf(const char *str)
{ {
/* do nothing -- not implemented yet */ // Just write the config file already...
return; config_write_config_gsport_file();
} }
int int