bug 498845 - libbz2 can't use fdopen on windows ce r=bsmedberg
author=Hiroyuki Ikezoe <ikezoe@clear-code.com>
Wed, 08 Jul 2009 11:49:47 -0400
changeset 30073 a152ab60e76d4be9d9be5e72c3ee7ed9fa834221
parent 30072 dfa5809bb978da23825c03efd6297a2311927220
child 30074 b7d5a56b44e78c1276b70e33376c49950188f02b
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbsmedberg
bugs498845
milestone1.9.2a1pre
bug 498845 - libbz2 can't use fdopen on windows ce r=bsmedberg
modules/libbz2/src/bzlib.c
--- a/modules/libbz2/src/bzlib.c
+++ b/modules/libbz2/src/bzlib.c
@@ -1366,17 +1366,33 @@ const char * BZ_API(BZ2_bzlibVersion)(vo
 {
    return BZ_VERSION;
 }
 
 
 #ifndef BZ_NO_STDIO
 /*---------------------------------------------------*/
 
-#if (defined(_WIN32) || defined(OS2) || defined(MSDOS)) && !defined(WINCE)
+#ifdef WINCE
+#ifndef setmode
+#define setmode _setmode
+#endif
+#ifndef O_BINARY
+#define O_BINARY _O_BINARY
+#endif
+static
+FILE * fdopen(int fd, const char *mode)
+{
+    wchar_t wMode[10];
+    MultiByteToWideChar(CP_ACP, 0, mode, -1, wMode, 10);
+    return _wfdopen((void*)fd, wMode);
+}
+#endif
+
+#if (defined(_WIN32) || defined(OS2) || defined(MSDOS))
 #   include <fcntl.h>
 #   include <io.h>
 #   define SET_BINARY_MODE(file) setmode(fileno(file),O_BINARY)
 #else
 #   define SET_BINARY_MODE(file)
 #endif
 static
 BZFILE * bzopen_or_bzdopen