diff options
-rw-r--r-- | include/mupdf/fitz/system.h | 8 | ||||
-rw-r--r-- | source/fitz/output.c | 2 | ||||
-rw-r--r-- | source/fitz/time.c | 19 |
3 files changed, 26 insertions, 3 deletions
diff --git a/include/mupdf/fitz/system.h b/include/mupdf/fitz/system.h index 3fe4311a..b49d9110 100644 --- a/include/mupdf/fitz/system.h +++ b/include/mupdf/fitz/system.h @@ -156,14 +156,15 @@ static int msvc_snprintf(char *str, size_t size, const char *fmt, ...) #define hypotf _hypotf -FILE *fz_fopen_utf8(const char *name, const char *mode); - #define fz_fopen fz_fopen_utf8 +#define fz_remove fz_remove_utf8 char *fz_utf8_from_wchar(const wchar_t *s); wchar_t *fz_wchar_from_utf8(const char *s); FILE *fz_fopen_utf8(const char *name, const char *mode); +int fz_remove_utf8(const char *name); + char **fz_argv_from_wargv(int argc, wchar_t **wargv); void fz_free_argv(int argc, char **argv); @@ -202,6 +203,9 @@ typedef int64_t fz_off_t; #ifndef fz_fopen #define fz_fopen fopen #endif +#ifndef fz_remove +#define fz_remove remove +#endif #define fz_fseek fseek #define fz_ftell ftell typedef int fz_off_t; diff --git a/source/fitz/output.c b/source/fitz/output.c index 55d2522f..a93ecc97 100644 --- a/source/fitz/output.c +++ b/source/fitz/output.c @@ -163,7 +163,7 @@ fz_new_output_with_path(fz_context *ctx, const char *filename, int append) /* Ensure we create a brand new file. We don't want to clobber our old file. */ if (!append) { - if (remove(filename) < 0) + if (fz_remove(filename) < 0) if (errno != ENOENT) fz_throw(ctx, FZ_ERROR_GENERIC, "cannot remove file '%s': %s", filename, strerror(errno)); } diff --git a/source/fitz/time.c b/source/fitz/time.c index 1f45e665..82805556 100644 --- a/source/fitz/time.c +++ b/source/fitz/time.c @@ -105,6 +105,25 @@ fz_fopen_utf8(const char *name, const char *mode) return file; } +int +fz_remove_utf8(const char *name) +{ + wchar_t *wname; + int n; + + wname = fz_wchar_from_utf8(name); + if (wname == NULL) + { + errno = ENOMEM; + return -1; + } + + n = _wremove(wname); + + free(wname); + return n; +} + char ** fz_argv_from_wargv(int argc, wchar_t **wargv) { |