Core: Skip conversion to UTF-16 if filesystem::path is based on it
This commit is contained in:
parent
36643f173b
commit
f2bc00d2ea
|
|
@ -33,7 +33,11 @@ namespace Nz
|
||||||
|
|
||||||
bool DynLibImpl::Load(const std::filesystem::path& libraryPath, std::string* errorMessage)
|
bool DynLibImpl::Load(const std::filesystem::path& libraryPath, std::string* errorMessage)
|
||||||
{
|
{
|
||||||
m_handle = LoadLibraryExW(ToWideString(libraryPath.generic_u8string()).data(), nullptr, (libraryPath.is_absolute()) ? LOAD_WITH_ALTERED_SEARCH_PATH : 0);
|
if constexpr (std::is_same_v<std::filesystem::path::value_type, wchar_t>)
|
||||||
|
m_handle = LoadLibraryExW(libraryPath.c_str(), nullptr, (libraryPath.is_absolute()) ? LOAD_WITH_ALTERED_SEARCH_PATH : 0);
|
||||||
|
else
|
||||||
|
m_handle = LoadLibraryExW(ToWideString(libraryPath.generic_u8string()).data(), nullptr, (libraryPath.is_absolute()) ? LOAD_WITH_ALTERED_SEARCH_PATH : 0);
|
||||||
|
|
||||||
if (m_handle)
|
if (m_handle)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,11 @@ namespace Nz
|
||||||
if ((mode & OpenMode::Lock) == 0)
|
if ((mode & OpenMode::Lock) == 0)
|
||||||
shareMode |= FILE_SHARE_WRITE;
|
shareMode |= FILE_SHARE_WRITE;
|
||||||
|
|
||||||
m_handle = CreateFileW(ToWideString(filePath.generic_u8string()).data(), access, shareMode, nullptr, openMode, 0, nullptr);
|
if constexpr (std::is_same_v<std::filesystem::path::value_type, wchar_t>)
|
||||||
|
m_handle = CreateFileW(filePath.c_str(), access, shareMode, nullptr, openMode, 0, nullptr);
|
||||||
|
else
|
||||||
|
m_handle = CreateFileW(ToWideString(filePath.generic_u8string()).data(), access, shareMode, nullptr, openMode, 0, nullptr);
|
||||||
|
|
||||||
return m_handle != INVALID_HANDLE_VALUE;
|
return m_handle != INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue