diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2012-04-20 16:00:13 +0200 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-04-20 16:10:02 +0100 |
commit | c6e27a74283a1fa31a930f1909dbc46e131f0447 (patch) | |
tree | b0104b5dd19f07fec8d2c03720c3efc8a8f60166 /fitz/stm_open.c | |
parent | 9fbd2de7411f6c87c6f1ad0d9adfba9fe5164e0f (diff) | |
download | mupdf-c6e27a74283a1fa31a930f1909dbc46e131f0447.tar.xz |
Pass UTF8 filename to fz_open_document / fz_open_file to remove kludges.
Use _wopen on a UTF8 -> wchar_t decoded filename to support UTF8 filenames
for win32.
Diffstat (limited to 'fitz/stm_open.c')
-rw-r--r-- | fitz/stm_open.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/fitz/stm_open.c b/fitz/stm_open.c index 1e303825..ced32d80 100644 --- a/fitz/stm_open.c +++ b/fitz/stm_open.c @@ -129,7 +129,21 @@ fz_open_fd(fz_context *ctx, int fd) fz_stream * fz_open_file(fz_context *ctx, const char *name) { +#ifdef _WIN32 + char *s = (char*)name; + wchar_t *wname, *d; + int c, fd; + d = wname = fz_malloc(ctx, (strlen(name)+1) * sizeof(wchar_t)); + while (*s) { + s += fz_chartorune(&c, s); + *d++ = c; + } + *d = 0; + fd = _wopen(wname, O_BINARY | O_RDONLY, 0); + fz_free(ctx, wname); +#else int fd = open(name, O_BINARY | O_RDONLY, 0); +#endif if (fd == -1) fz_throw(ctx, "cannot open %s", name); return fz_open_fd(ctx, fd); |