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
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
@ -143,7 +143,7 @@ x_show_alert(int is_fatal, const char *str)
if(str) {
// Provide an extra option--create a file
cfstrref2 = CFStringCreateWithFormat(kCFAllocatorDefault, NULL,
CFSTR("Create ~/%s"), str);
CFSTR("Create ./%s"), str);
alert_param.otherText = cfstrref2;
}
okstrref = CFSTR("Click OK to continue");
@ -201,10 +201,7 @@ x_dialog_create_gsport_conf(const char *str)
ret = x_show_alert(1, str);
if(ret) {
// Create empty file
path = "~";
snprintf(tmp_buf, 500, "touch %s/%s", path, str);
system(tmp_buf);
config_write_config_gsport_file();
}
}

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] = "./";
const char *g_gsport_default_paths[] = { "", "./", "${HOME}/","${CD}/",
const char *g_gsport_default_paths[] = { "", "./", "${HOME}/","${CD}/","${PWD}/",
"${HOME}/Library/GSport/",
"${0}/Contents/Resources/", "/usr/local/lib/",
"/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
gsport_expand_path(&(local_path[0]), "${CD}/config.txt", 250);
#else
// Non-windows - use home directory
gsport_expand_path(&(local_path[0]), "${HOME}/config.txt", 250);
// Non-windows - use pwd to get current directory
gsport_expand_path(&(local_path[0]), "${PWD}/config.txt", 250);
#endif
strcpy(outname, &(local_path[0]));
// Ask user if it's OK to create the file

View File

@ -1,6 +1,6 @@
/*
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
@ -260,8 +260,8 @@ main(int argc, char **argv)
void
x_dialog_create_gsport_conf(const char *str)
{
/* do nothing -- not implemented yet */
return;
// Just write the config file already...
config_write_config_gsport_file();
}
int