summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorallen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-10-18 09:02:41 +0000
committerallen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-10-18 09:02:41 +0000
commit6864074b9e678aab32ca76703cd0bbb358ee05f5 (patch)
treefb541170c4199dc5998c728a45285dee486aac3f
parent51804dff1d0034d40f5e323d7ca0b49be49cb806 (diff)
Only try and create each directory name once
git-svn-id: http://svn.cactuscode.org/flesh/trunk@1048 17b73243-c579-4c4c-a9d2-2d5706c11dac
-rw-r--r--src/util/File.c46
1 files 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;