From 6864074b9e678aab32ca76703cd0bbb358ee05f5 Mon Sep 17 00:00:00 2001 From: allen Date: Mon, 18 Oct 1999 09:02:41 +0000 Subject: Only try and create each directory name once git-svn-id: http://svn.cactuscode.org/flesh/trunk@1048 17b73243-c579-4c4c-a9d2-2d5706c11dac --- src/util/File.c | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/src/util/File.c b/src/util/File.c index 541693c3..56682dfc 100644 --- a/src/util/File.c +++ b/src/util/File.c @@ -4,9 +4,9 @@ /*@@ @file File.c @date September 6th 1999 - @author File handling routines + @author Gabrielle Allen @desc - Miscellaneuous routines. + File Handling routines @enddesc @@*/ @@ -15,15 +15,39 @@ #include "cctk_WarnLevel.h" #include "cctk_FortranString.h" +#include "StoreHandledData.h" + +static cHandledData *DirNames = NULL; + + /*@@ + @routine CCTK_mkdir + @date September 6th 1999 + @author Gabrielle Allen + @desc + Create a directory, if we haven't already tried + to create it. + @enddesc + @@*/ int CCTK_mkdir(char *dir) { int retval; + int handle; char *command; char *message; command = (char *)malloc(1024*sizeof(char)); + /* Store directory name */ + handle = Util_GetHandle(DirNames, dir, NULL); + + + if (handle < 0) + { + + /* New directory name */ + handle = Util_NewHandle(&DirNames, dir, NULL); + /*** TR 13/09/99: disabled use of MKDIRFLAGS until it also works for NT This means either @@ -36,19 +60,21 @@ int CCTK_mkdir(char *dir) relative to an existing directory. ***/ #if 0 - sprintf(command, MKDIR MKDIRFLAGS " %s",dir); + sprintf(command, MKDIR MKDIRFLAGS " %s",dir); #else - sprintf(command, MKDIR " %s",dir); + sprintf(command, MKDIR " %s",dir); #endif - message = (char *)malloc(1024*sizeof(char)); - sprintf(message,"Creating directory: \"%s\"",command); - CCTK_Info("Cactus",message); - free(message); + message = (char *)malloc(1024*sizeof(char)); + sprintf(message,"Creating directory: \"%s\"",command); + CCTK_Info("Cactus",message); + free(message); + + retval = system(command); - retval = system(command); + free(command); - free(command); + } return retval; -- cgit v1.2.3