diff options
author | tradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880> | 2000-04-18 09:02:34 +0000 |
---|---|---|
committer | tradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880> | 2000-04-18 09:02:34 +0000 |
commit | 3a5c17575b65622e6606081c8278c6b993d236ff (patch) | |
tree | 51d86b98d309ebfc65219e9e23882ea32bc6431c /src | |
parent | 34c967c887bbcad5eb62a4923f41e261ebe7b382 (diff) |
Using stat(2) rather than access(2) to check for already exisiting output
files. This should work now for both Unix and NT.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOBasic/trunk@52 b589c3ab-70e8-4b4d-a09f-cba2dd200880
Diffstat (limited to 'src')
-rw-r--r-- | src/Write.c | 10 | ||||
-rw-r--r-- | src/WriteGF.c | 10 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/Write.c b/src/Write.c index f5d8809..4174304 100644 --- a/src/Write.c +++ b/src/Write.c @@ -15,16 +15,15 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> /* strlen(3) */ +#include <sys/types.h> +#include <sys/stat.h> /* stat(2) */ #include "cctk.h" #include "cctk_Parameters.h" #include "CactusBase/IOUtil/src/ioGH.h" #include "iobasicGH.h" -#ifdef HAVE_UNISTD_H -#include <unistd.h> /* access(2) */ -#endif - void IOBasic_Write (cGH *GH, int index, const char *alias) { @@ -58,6 +57,7 @@ void IOBasic_Write (cGH *GH, int index, const char *alias) { char *fname; iobasicGH *myGH; + struct stat fileinfo; myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")]; @@ -69,7 +69,7 @@ void IOBasic_Write (cGH *GH, int index, const char *alias) /* if restart from recovery, all existing files are opened in append mode */ if (ioUtilGH->recovered) - openmode = access (fname, F_OK) == 0 ? "a" : "w"; + openmode = stat (fname, &fileinfo) == 0 ? "a" : "w"; else openmode = "w"; } else diff --git a/src/WriteGF.c b/src/WriteGF.c index 7852ecb..7e1e254 100644 --- a/src/WriteGF.c +++ b/src/WriteGF.c @@ -15,16 +15,15 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> /* strlen(3) */ +#include <sys/types.h> +#include <sys/stat.h> /* stat(2) */ #include "cctk.h" #include "cctk_Parameters.h" #include "CactusBase/IOUtil/src/ioGH.h" #include "iobasicGH.h" -#ifdef HAVE_UNISTD_H -#include <unistd.h> /* access(2) */ -#endif - void IOBasic_WriteGF (cGH *GH, int index, const char *alias) { @@ -38,6 +37,7 @@ void IOBasic_WriteGF (cGH *GH, int index, const char *alias) char title_start_char; int reduction_handle; int decnot; + struct stat fileinfo; CCTK_REAL reduction_value; /* add more reductions to this table if you want, telling it @@ -111,7 +111,7 @@ void IOBasic_WriteGF (cGH *GH, int index, const char *alias) /* if restart from recovery, all existing files are opened in append mode */ if (ioUtilGH->recovered) - openmode = access (filename, F_OK) == 0 ? "a" : "w"; + openmode = stat (filename, &fileinfo) == 0 ? "a" : "w"; else openmode = "w"; } else |