Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode Compiler Error Fix #214

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/io-util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <io.h>
#include <windows.h> // include API for expanding a file path
#include <tchar.h>

#ifndef TINYUSDZ_MMAP_SUPPORTED
#define TINYUSDZ_MMAP_SUPPORTED (1)
Expand Down Expand Up @@ -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<TCHAR> 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,
Copy link

@spham-amzn spham-amzn Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of possibly converting the filename to a char or wide character, why no use CreateFileA directly so it always uses char? CreateFile is really a macro that switches between CreateFileA and CreateFileW based on the unicode switch anyways

OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hFile == INVALID_HANDLE_VALUE) {
if (err) {
Expand Down
Loading