foxygit / doom Log in
commit bdeaec12d0f79c5cd15b49105a11988ac5ec545c
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Sun Jun 7 23:41:10 2009 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Sun Jun 7 23:41:10 2009 +0000

    Use CreateFileW instead of OpenFile (doesn't exist on Windows CE)

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 1576
---
 src/w_file_win32.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/w_file_win32.c b/src/w_file_win32.c
index d5e60579..ec17cf6c 100644
--- a/src/w_file_win32.c
+++ b/src/w_file_win32.c
@@ -94,12 +94,24 @@ unsigned int GetFileLength(HANDLE handle)
 static wad_file_t *W_Win32_OpenFile(char *path)
 {
     win32_wad_file_t *result;
+    wchar_t wpath[MAX_PATH + 1];
     HANDLE handle;
-    OFSTRUCT fileinfo;

-    handle = (HANDLE) OpenFile(path, &fileinfo, OF_READ);
+    // Open the file:

-    if (handle == (HANDLE) HFILE_ERROR)
+    MultiByteToWideChar(CP_OEMCP, 0,
+                        path, strlen(path) + 1,
+                        wpath, sizeof(wpath));
+
+    handle = CreateFileW(wpath,
+                         GENERIC_READ,
+                         FILE_SHARE_READ,
+                         NULL,
+                         OPEN_EXISTING,
+                         FILE_ATTRIBUTE_NORMAL,
+                         NULL);
+
+    if (handle == INVALID_HANDLE_VALUE)
     {
         return NULL;
     }