diff options
Diffstat (limited to 'filter/filec.c')
-rw-r--r-- | filter/filec.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/filter/filec.c b/filter/filec.c index f62d1265..fc5599e1 100644 --- a/filter/filec.c +++ b/filter/filec.c @@ -13,15 +13,20 @@ fz_openfile(fz_file **filep, char *path, int mode) { fz_error *error; fz_file *file; + int realmode; int fd; - assert(mode == O_RDONLY || mode == O_WRONLY); + assert(mode == O_RDONLY || mode == O_WRONLY || mode == O_APPEND); + + realmode = mode; + if (mode == O_WRONLY) + realmode = O_WRONLY | O_CREAT | O_TRUNC; file = *filep = fz_malloc(sizeof(fz_file)); if (!file) return fz_outofmem; - fd = open(path, mode, 0); + fd = open(path, realmode, 0644); if (fd == -1) return fz_throw("ioerror: open '%s': %s", path, strerror(errno)); |