aboutsummaryrefslogtreecommitdiff
path: root/src/indexamajig.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2013-02-22 18:12:20 +0100
committerThomas White <taw@physics.org>2013-02-22 18:12:20 +0100
commit2c439230bad3907f5fc93b3e69ade0d5a5acc4b4 (patch)
tree7fea1fe4854fff36709d202b4c6192d72f24e7ce /src/indexamajig.c
parentfe8352bf60638f0da55669bd9e55a75ad7e300e4 (diff)
Avoid the use of stdio for writing to final stream
Something really weird goes on when using stdio
Diffstat (limited to 'src/indexamajig.c')
-rw-r--r--src/indexamajig.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/indexamajig.c b/src/indexamajig.c
index b88469b8..41662d5f 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -44,6 +44,9 @@
#include <getopt.h>
#include <hdf5.h>
#include <gsl/gsl_errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#ifdef HAVE_CLOCK_GETTIME
#include <time.h>
@@ -158,7 +161,7 @@ int main(int argc, char *argv[])
char *filename = NULL;
char *outfile = NULL;
FILE *fh;
- FILE *ofh;
+ int ofd;
char *rval = NULL;
int config_checkprefix = 1;
int config_basename = 0;
@@ -510,8 +513,8 @@ int main(int argc, char *argv[])
iargs.cell = NULL;
}
- ofh = fopen(outfile, "w");
- if ( ofh == NULL ) {
+ ofd = open(outfile, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR);
+ if ( ofd == -1 ) {
ERROR("Failed to open stream '%s'\n", outfile);
return 1;
}
@@ -553,7 +556,7 @@ int main(int argc, char *argv[])
iargs.ipriv = ipriv;
create_sandbox(&iargs, n_proc, prefix, config_basename, fh,
- use_this_one_instead, ofh, argc, argv);
+ use_this_one_instead, ofd, argc, argv);
free(prefix);