From 6ad746ff19a2627c1969d80b150e029066c5703a Mon Sep 17 00:00:00 2001 From: tradke Date: Mon, 13 Sep 1999 11:56:58 +0000 Subject: Use CCTK_mkdir for creating directories. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOFlexIO/trunk@33 ebee0441-1374-4afa-a3b5-247f3ba15b9a --- src/GHExtension.c | 26 +++++++------------------- src/Write3D.c | 19 ++++++++----------- 2 files changed, 15 insertions(+), 30 deletions(-) (limited to 'src') 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; iextensions [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 -- cgit v1.2.3