Skip to content
Open
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
20 changes: 18 additions & 2 deletions pxr/base/arch/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <dlfcn.h>
#endif

#include <filesystem>

PXR_NAMESPACE_OPEN_SCOPE

#if defined(ARCH_OS_WINDOWS)
Expand All @@ -31,10 +33,24 @@ void* ArchLibraryOpen(const std::string &filename, int flag)
if (void* result = LoadLibraryW(std::filesystem::u8path(filename).c_str())) {
return result;
}
else {

arch_lastLibraryError = GetLastError();

// If library failed to load because the path is too long
// try to use a UNC file name, this helps work around windows MAX_PATH issues
if (ERROR_FILENAME_EXCED_RANGE == arch_lastLibraryError) {
std::filesystem::path uncpath("\\\\?\\");
uncpath += std::filesystem::absolute(filename);

if (void* result = LoadLibrary(uncpath.string().c_str())) {
arch_lastLibraryError = 0;
return result;
}

arch_lastLibraryError = GetLastError();
return nullptr;
}

return nullptr;
#else
// Clear any unchecked error first.
(void)dlerror();
Expand Down
Loading