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 24730ab477f0794b2f3a4d587f1cda8664ffff61..ee2b2941c8448ed13821855e9cb5a65669f49e68 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 ce94b049106dd4b1a57ed060b9be45fa1bfb9802..0c5c51cdb47594afcc5d7738f26b76bf418538ca 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 bef8da65fd946550cd4e6c12791606e367364245..103923629f138dd88afe223b6d9b94e5ddf9f824 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);