aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a>1999-09-13 11:56:58 +0000
committertradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a>1999-09-13 11:56:58 +0000
commit6ad746ff19a2627c1969d80b150e029066c5703a (patch)
tree1b8ead45e150a68134efd89e202fc33933820663 /src
parent36c1b54b2a6985ffd6a42e631203283e8fefbdf1 (diff)
Use CCTK_mkdir for creating directories.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOFlexIO/trunk@33 ebee0441-1374-4afa-a3b5-247f3ba15b9a
Diffstat (limited to 'src')
-rw-r--r--src/GHExtension.c26
-rw-r--r--src/Write3D.c19
2 files changed, 15 insertions, 30 deletions
diff --git a/src/GHExtension.c b/src/GHExtension.c
index cdbcc85..52c9cf6 100644
--- a/src/GHExtension.c
+++ b/src/GHExtension.c
@@ -84,25 +84,13 @@ int IOFlexIO_InitGH (cGH *GH)
myGH->outpfx_3D = outdir3D;
/* Create the output directories */
- if (myGH->IO_2Devery > 0) {
- if (CCTK_MyProc (GH) == 0) {
- char *command = (char *) malloc (1024 * sizeof (char));
-
- sprintf (command, "mkdir -p %s", myGH->outpfx_2D);
- if (system (command) < 0)
- CCTK_WARN (1,"Problem creating IO 2D directory");
- free (command);
- }
- }
- if (myGH->IO_3Devery > 0) {
- if (CCTK_MyProc (GH) == 0) {
- char *command = (char *) malloc (1024 * sizeof (char));
-
- sprintf (command, "mkdir -p %s", myGH->outpfx_3D);
- if (system (command) < 0)
- CCTK_WARN (1,"Problem creating IO 3D directory");
- free (command);
- }
+ if (CCTK_MyProc (GH) == 0) {
+ if (myGH->IO_2Devery > 0 && strcmp (myGH->outpfx_2D, "."))
+ if (CCTK_mkdir (myGH->outpfx_2D) != 0)
+ CCTK_WARN (2,"Problem creating IO 2D directory");
+ if (myGH->IO_3Devery > 0 && strcmp (myGH->outpfx_3D, "."))
+ if (CCTK_mkdir (myGH->outpfx_3D) != 0)
+ CCTK_WARN (2,"Problem creating IO 3D directory");
}
for (i=0; i<CCTK_NumVars(); i++)
diff --git a/src/Write3D.c b/src/Write3D.c
index 2d30a43..e237f12 100644
--- a/src/Write3D.c
+++ b/src/Write3D.c
@@ -359,9 +359,9 @@ IEEEfile_3D_t *IOFlexIO_Get3Dfile (cGH *GH, const char *alias, int *isNewFile)
flexioGH *myGH; /* handle for IOFlexIO extensions */
int nprocs;
int myproc;
- char extra [256]; /* Extra stuff in fname based on mode */
- char extradir [256]; /* Extra stuff for an output dir */
- char createdir [256]; /* Text for system call to create output directory */
+ char extra [256]; /* Extra stuff in fname based on mode */
+ char extradir [256]; /* Extra stuff for an output dir */
+ char *outputdir; /* the output directory to be created */
IEEEfile_3D_t *IEEEfile_3D;
myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")];
@@ -417,15 +417,12 @@ IEEEfile_3D_t *IOFlexIO_Get3Dfile (cGH *GH, const char *alias, int *isNewFile)
/* If necessary create the output directory */
if (myproc == 0) {
- sprintf (createdir, "mkdir -p %s/%s_3d", myGH->outpfx_3D, alias);
+ sprintf (outputdir, "%s/%s_3d", myGH->outpfx_3D, alias);
- if (verbose) {
- printf ("Creating output directory with command\n %s\n", createdir);
- fflush (stdout);
- }
-
- if (system (createdir) != 0)
- printf ("Could not create directory\n");
+ if (CCTK_mkdir (outputdir) != 0)
+ CCTK_WARN (1, "Problem creating 3D output directory");
+
+ free (outputdir);
}
#ifdef MPI