win32_read_file: Use UTF16-LE name
authorEric Biggers <ebiggers3@gmail.com>
Fri, 22 Mar 2013 16:01:39 +0000 (11:01 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Fri, 22 Mar 2013 16:01:39 +0000 (11:01 -0500)
src/resource.c
src/win32.c
src/win32.h

index 24730ab..ee2b294 100644 (file)
 #  include <ntfs-3g/dir.h>
 #endif
 
+#if defined(__WIN32__) && !defined(INVALID_HANDLE_VALUE)
+#  define INVALID_HANDLE_VALUE ((HANDLE)(-1))
+#endif
+
 /*
  * Reads all or part of a compressed resource into an in-memory buffer.
  *
@@ -570,9 +574,10 @@ read_wim_resource(const struct wim_lookup_table_entry *lte, void *buf,
                break;
 #ifdef __WIN32__
        case RESOURCE_WIN32:
-               wimlib_assert(lte->file_on_disk_fp != NULL);
-               ret = win32_read_file(lte->file_on_disk, lte->file_on_disk_fp,
-                                     offset, size, buf);
+               wimlib_assert(lte->win32_file_on_disk_fp != INVALID_HANDLE_VALUE);
+               ret = win32_read_file(lte->win32_file_on_disk,
+                                     lte->win32_file_on_disk_fp, offset, size,
+                                     buf);
                break;
 #endif
        case RESOURCE_IN_ATTACHED_BUFFER:
index ce94b04..0c5c51c 100644 (file)
@@ -159,7 +159,7 @@ win32_open_file_data_only(const wchar_t *path)
 }
 
 int
-win32_read_file(const mbchar *filename,
+win32_read_file(const utf16lechar *win32_filename,
                void *handle, u64 offset, size_t size, void *buf)
 {
        HANDLE h = handle;
@@ -173,7 +173,7 @@ win32_read_file(const mbchar *filename,
                if (ReadFile(h, buf, size, &bytesRead, NULL) && bytesRead == size)
                        return 0;
        err = GetLastError();
-       ERROR("Error reading \"%s\"", filename);
+       ERROR("Error reading \"%ls\"", win32_filename);
        win32_error(err);
        return WIMLIB_ERR_READ;
 }
index bef8da6..1039236 100644 (file)
@@ -16,8 +16,8 @@ win32_build_dentry_tree(struct wim_dentry **root_ret,
                        void *extra_arg);
 
 extern int
-win32_read_file(const mbchar *filename, void *handle, u64 offset,
-               size_t size, void *buf);
+win32_read_file(const utf16lechar *win32_filename, void *handle,
+               u64 offset, size_t size, void *buf);
 
 extern HANDLE
 win32_open_file_data_only(const wchar_t *path_utf16);