diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 3143a7e80..01a53fa0b 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -5988,7 +5988,7 @@ static void setup(int argc, char *argv[]) dont_load_stamps = 0; no_system_fonts = 1; print_delay = 0; - use_print_config = 0; + use_print_config = 1; mirrorstamps = 0; disable_stamp_controls = 0; @@ -6511,7 +6511,11 @@ static void setup(int argc, char *argv[]) /* Look for the lockfile... */ +#ifndef WIN32 lock_fname = get_fname("lockfile.dat"); +#else + lock_fname = get_temp_fname("lockfile.dat"); +#endif fi = fopen(lock_fname, "r"); if (fi != NULL) @@ -11330,7 +11334,11 @@ static void cleanup(void) time_t zero_time; FILE *fi; +#ifndef WIN32 lock_fname = get_fname("lockfile.dat"); +#else + lock_fname = get_temp_fname("lockfile.dat"); +#endif zero_time = (time_t) 0; diff --git a/src/win32_print.c b/src/win32_print.c index c4511dd42..519fc28fe 100644 --- a/src/win32_print.c +++ b/src/win32_print.c @@ -576,3 +576,29 @@ char *GetSystemFontDir(void) } return strdup("C:\\WINDOWS\\FONTS"); } + +/* + Returns heap string containing user temp directory. + E.g. C:\Documents and Settings\jfp\Local Settings\Temp +*/ +static char *GetUserTempDir(void) +{ + char *temp = getenv("TEMP"); + + if (!temp) + { + temp = "userdata"; + } + return strdup(temp); +} + +char *get_temp_fname(const char *const name) +{ + char f[512]; + char *tempdir = GetUserTempDir(); + + snprintf(f, sizeof(f), "%s/%s", tempdir, name); + free(tempdir); + return strdup(f); +} + diff --git a/src/win32_print.h b/src/win32_print.h index b4986121b..fb3c9e136 100644 --- a/src/win32_print.h +++ b/src/win32_print.h @@ -22,5 +22,6 @@ extern int IsPrinterAvailable(void); /* additional windows functions requiring */ extern char *GetDefaultSaveDir(const char *suffix); extern char *GetSystemFontDir(void); +extern char *get_temp_fname(const char *const name); #endif