From aead0632b99582d27d81e751cb41a42305d891b3 Mon Sep 17 00:00:00 2001 From: William Kendrick Date: Fri, 11 Mar 2005 05:37:58 +0000 Subject: [PATCH] Makes our tuxpaint dir (in case it doesn't exist yet) before writing lockfile --- docs/CHANGES.txt | 3 +++ src/tuxpaint.c | 16 +++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index 87d26b295..c45b1f402 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -120,6 +120,9 @@ http://www.newbreedsoftware.com/tuxpaint/ * Now uses "AUDIO_S16SYS" when initializing audio system (on Linux/Mac/BeOS); helps sound under Linux on Mac hardware. Albert Cahalan + + * Made sure user directory existed before trying to create lockfile + (it might not be there the very first time we run Tux Paint). * Interface improvements: ----------------------- diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 6e395d123..95ddab74c 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -22,12 +22,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - June 14, 2002 - February 13, 2005 + June 14, 2002 - March 10, 2005 */ #define VER_VERSION "0.9.15" -#define VER_DATE "2005-02-13" +#define VER_DATE "2005-03-10" /* Color depth for Tux Paint to run in, and store canvases in: */ @@ -7715,6 +7715,7 @@ static void setup(int argc, char * argv[]) { char * lock_fname; time_t time_lock, time_now; + char * homedirdir; /* Get the current time: */ @@ -7753,6 +7754,12 @@ static void setup(int argc, char * argv[]) /* Okay to run; create/update the lockfile */ + /* (Make sure the directory exists, first!) */ + homedirdir = get_fname(""); + mkdir(homedirdir, 0755); + free(homedirdir); + + fi = fopen(lock_fname, "w"); if (fi != NULL) { @@ -11464,10 +11471,9 @@ static char * get_fname(const char * const name) strcpy(f, savedir); else snprintf(f, sizeof(f), "%s/%s", savedir, name); + #else - /* On Mac, Linux and other Unixes, it's in a place under our home dir.: */ - - + #ifdef __APPLE__ /* Macintosh: It's under ~/Library/Application Support/TuxPaint */