From 090c7857a0ad754b9a87a91262c42ca197c6a2e9 Mon Sep 17 00:00:00 2001 From: Gene Walters Date: Tue, 3 Dec 2024 11:58:24 -0800 Subject: [PATCH 1/2] Using TCHAR string to fix compiler error when compiling with UNICODE Signed-off-by: Gene Walters --- src/io-util.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/io-util.cc b/src/io-util.cc index 4146303d..77906dec 100644 --- a/src/io-util.cc +++ b/src/io-util.cc @@ -19,6 +19,7 @@ #include #include // include API for expanding a file path +#include #ifndef TINYUSDZ_MMAP_SUPPORTED #define TINYUSDZ_MMAP_SUPPORTED (1) @@ -153,9 +154,10 @@ bool MMapFile(const std::string &filepath, MMapFileHandle *handle, #if TINYUSDZ_MMAP_SUPPORTED #if defined(_WIN32) - // int fd = open(filepath.c_str(), writable ? O_RDWR : O_RDONLY); + std::basic_string tFilepath(filepath.begin(), filepath.end()); // Using TCHAR string to automatically use normal or wide characters if UNICODE is enabled + HANDLE hFile = - CreateFile(filepath.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, + CreateFile(tFilepath.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile == INVALID_HANDLE_VALUE) { if (err) { From ad76ce83e2c2ddc2f8978cea00148f7f41f49c8d Mon Sep 17 00:00:00 2001 From: Gene Walters Date: Tue, 3 Dec 2024 12:06:07 -0800 Subject: [PATCH 2/2] Minor. Whitespace fixes Signed-off-by: Gene Walters --- src/io-util.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/io-util.cc b/src/io-util.cc index 77906dec..d67b8105 100644 --- a/src/io-util.cc +++ b/src/io-util.cc @@ -154,10 +154,10 @@ bool MMapFile(const std::string &filepath, MMapFileHandle *handle, #if TINYUSDZ_MMAP_SUPPORTED #if defined(_WIN32) - std::basic_string tFilepath(filepath.begin(), filepath.end()); // Using TCHAR string to automatically use normal or wide characters if UNICODE is enabled + std::basic_string tFilepath(filepath.begin(), filepath.end()); // Using TCHAR string to automatically use normal or wide characters if UNICODE is enabled HANDLE hFile = - CreateFile(tFilepath.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, + CreateFile(tFilepath.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile == INVALID_HANDLE_VALUE) { if (err) {