diff options
author | Thomas White <taw@physics.org> | 2013-02-05 16:21:40 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2013-02-05 16:21:40 +0100 |
commit | 2ce85a95d86e350b785d206405e97d7317672188 (patch) | |
tree | 5cecce161733acf1a276e5a0b55e5c22f5ffb20d /libcrystfel/src/stream.c | |
parent | 29cca07716b48f9e433087f5dbb202165b1897e1 (diff) |
Indexing pipeline - "done"!
Diffstat (limited to 'libcrystfel/src/stream.c')
-rw-r--r-- | libcrystfel/src/stream.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c index 31fb8527..113dc359 100644 --- a/libcrystfel/src/stream.c +++ b/libcrystfel/src/stream.c @@ -38,6 +38,9 @@ #include <stdio.h> #include <string.h> #include <assert.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> #include "cell.h" #include "utils.h" @@ -236,6 +239,8 @@ void write_chunk(Stream *st, struct image *i, struct hdfile *hdfile, } fprintf(st->fh, CHUNK_END_MARKER"\n\n"); + + fflush(st->fh); } @@ -497,14 +502,14 @@ Stream *open_stream_for_read(const char *filename) } -Stream *open_stream_for_write(const char *filename) +Stream *open_stream_fd_for_write(int fd) { Stream *st; st = malloc(sizeof(struct _stream)); if ( st == NULL ) return NULL; - st->fh = fopen(filename, "w"); + st->fh = fdopen(fd, "w"); if ( st->fh == NULL ) { free(st); return NULL; @@ -520,6 +525,21 @@ Stream *open_stream_for_write(const char *filename) } + +Stream *open_stream_for_write(const char *filename) +{ + int fd; + + fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR); + if ( fd == -1 ) { + ERROR("Failed to open stream.\n"); + return NULL; + } + + return open_stream_fd_for_write(fd); +} + + void close_stream(Stream *st) { fclose(st->fh); |