--- main.cpp.old 2006-01-30 20:26:46.000000000 +0100 +++ main.cpp 2006-01-30 20:27:20.000000000 +0100 @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include +#include +#include + #include "file.h" #include "game.h" #include "systemstub.h" @@ -24,9 +28,9 @@ "REminiscence - Flashback Interpreter\n" "Usage: rs [OPTIONS]...\n" " --datapath=PATH Path to data files (default 'DATA')\n" - " --savepath=PATH Path to save files (default '.')"; + " --savepath=PATH Path to save files (default '~/.reminiscence/')\n"; -static bool parseOption(const char *arg, const char *longCmd, const char **opt) { +static bool parseOption(char *arg, const char *longCmd, char **opt) { bool handled = false; if (arg[0] == '-' && arg[1] == '-') { if (strncmp(arg + 2, longCmd, strlen(longCmd)) == 0) { @@ -59,8 +63,18 @@ #undef main int main(int argc, char *argv[]) { - const char *dataPath = "DATA"; - const char *savePath = "."; + struct stat sb; + char *dataPath = "DATA"; + char *savePath = (char *)malloc(256); + + snprintf(savePath, sizeof(savePath) * 255, "%s/.reminiscence", getenv("HOME")); + + if (stat(savePath, &sb)) { + if (mkdir(savePath, 0755) == -1) { + error("Unable to create %s directory", savePath); + } + } + for (int i = 1; i < argc; ++i) { bool opt = false; if (strlen(argv[i]) >= 2) {