diff options
author | Tor Andersson <tor@ghostscript.com> | 2004-10-05 09:52:44 +0200 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2004-10-05 09:52:44 +0200 |
commit | 9ce9759c580d5522ad2d3812b26aff49644d8881 (patch) | |
tree | 2eb3aa263955f7bdfe4461624aa3dfe8d9992e83 /filter/filec.c | |
parent | 7ad0eac4b8c81c5123ef5a62b23ba2895dd997c8 (diff) | |
download | mupdf-9ce9759c580d5522ad2d3812b26aff49644d8881.tar.xz |
improved reading to buffers and writing files
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)); |