diff options
-rw-r--r-- | source/fitz/output.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/source/fitz/output.c b/source/fitz/output.c index 18791603..a8301a1e 100644 --- a/source/fitz/output.c +++ b/source/fitz/output.c @@ -205,7 +205,7 @@ fz_new_output_with_path(fz_context *ctx, const char *filename, int append) if (errno != ENOENT) fz_throw(ctx, FZ_ERROR_GENERIC, "cannot remove file '%s': %s", filename, strerror(errno)); } - file = fz_fopen_utf8(filename, "rb+"); + file = fz_fopen_utf8(filename, append ? "rb+" : "wb+"); #else /* Ensure we create a brand new file. We don't want to clobber our old file. */ if (!append) @@ -214,7 +214,7 @@ fz_new_output_with_path(fz_context *ctx, const char *filename, int append) if (errno != ENOENT) fz_throw(ctx, FZ_ERROR_GENERIC, "cannot remove file '%s': %s", filename, strerror(errno)); } - file = fopen(filename, "rb+"); + file = fopen(filename, append ? "rb+" : "wb+"); #endif if (!file) fz_throw(ctx, FZ_ERROR_GENERIC, "cannot open file '%s': %s", filename, strerror(errno)); |