From 9ce9759c580d5522ad2d3812b26aff49644d8881 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 5 Oct 2004 09:52:44 +0200 Subject: improved reading to buffers and writing files --- filter/filec.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'filter/filec.c') 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)); -- cgit v1.2.3