1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2026-01-10 18:30:54 +00:00

Support long paths on Windows

Apparently we'd never bothered opting in, despite nearly everything in all out apps being entirely compatible and designed with long paths in mind.

GetModuleFileNameW is a bit awkward as it's just about the only Win32 function that returns the minimum of the buffer size and the string size - nearly everything else returns the full size even if it won't fit, so you can pass it a null pointer and a size of zero, and it'll tell you how much space you need to allocate.

I pretty much just copied the mostly-working long-path-friendly call site in the crash catcher to windowspath.cpp, but I also noticed that if the function failed and returned zero, the original implementation would loop forever, so I fixed that.

There was some code that could be ditched from the catch monitor as \\?\ is a prefix you can use to opt into long paths for a single API call instead of using the manifest to set it everywhere.
This commit is contained in:
AnyOldName3 2025-12-18 16:30:06 +00:00
parent 7d9eee3f33
commit 16efa6e5b5
20 changed files with 66 additions and 7 deletions

View file

@ -13,3 +13,7 @@ if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw_detournavigator_navmeshtilescache_benchmark PRIVATE --coverage)
target_link_libraries(openmw_detournavigator_navmeshtilescache_benchmark gcov)
endif()
if (WIN32)
target_sources(openmw_detournavigator_navmeshtilescache_benchmark PRIVATE ${CMAKE_SOURCE_DIR}/files/windows/other-apps.manifest)
endif()

View file

@ -13,3 +13,7 @@ if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw_esm_refid_benchmark PRIVATE --coverage)
target_link_libraries(openmw_esm_refid_benchmark gcov)
endif()
if (WIN32)
target_sources(openmw_esm_refid_benchmark PRIVATE ${CMAKE_SOURCE_DIR}/files/windows/other-apps.manifest)
endif()

View file

@ -16,3 +16,7 @@ if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw_settings_access_benchmark PRIVATE --coverage)
target_link_libraries(openmw_settings_access_benchmark gcov)
endif()
if (WIN32)
target_sources(openmw_settings_access_benchmark PRIVATE ${CMAKE_SOURCE_DIR}/files/windows/other-apps.manifest)
endif()

View file

@ -13,6 +13,10 @@ target_link_libraries(bsatool
components
)
if (WIN32)
target_sources(bsatool PRIVATE ${CMAKE_SOURCE_DIR}/files/windows/other-apps.manifest)
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(bsatool PRIVATE --coverage)
target_link_libraries(bsatool gcov)

View file

@ -10,6 +10,10 @@ target_link_libraries(openmw-bulletobjecttool
components
)
if (WIN32)
target_sources(openmw-bulletobjecttool PRIVATE ${CMAKE_SOURCE_DIR}/files/windows/other-apps.manifest)
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-bulletobjecttool PRIVATE --coverage)
target_link_libraries(openmw-bulletobjecttool gcov)

View file

@ -107,6 +107,10 @@ target_link_libraries(components-tests
components
)
if (WIN32)
target_sources(components-tests PRIVATE ${CMAKE_SOURCE_DIR}/files/windows/other-apps.manifest)
endif()
# Fix for not visible pthreads functions for linker with glibc 2.15
if (UNIX AND NOT APPLE)
target_link_libraries(components-tests ${CMAKE_THREAD_LIBS_INIT})

View file

@ -20,6 +20,10 @@ target_link_libraries(esmtool
components
)
if (WIN32)
target_sources(esmtool PRIVATE ${CMAKE_SOURCE_DIR}/files/windows/other-apps.manifest)
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(esmtool PRIVATE --coverage)
target_link_libraries(esmtool gcov)

View file

@ -37,6 +37,10 @@ target_link_libraries(openmw-essimporter
components
)
if (WIN32)
target_sources(openmw-essimporter PRIVATE ${CMAKE_SOURCE_DIR}/files/windows/other-apps.manifest)
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-essimporter PRIVATE --coverage)
target_link_libraries(openmw-essimporter gcov)

View file

@ -74,6 +74,10 @@ target_link_libraries(openmw-launcher
target_link_libraries(openmw-launcher Qt::Widgets Qt::Core Qt::Svg)
if (WIN32)
target_sources(openmw-launcher PRIVATE ${CMAKE_SOURCE_DIR}/files/windows/other-apps.manifest)
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-launcher PRIVATE --coverage)
target_link_libraries(openmw-launcher gcov)

View file

@ -18,6 +18,10 @@ target_link_libraries(openmw-iniimporter
components
)
if (WIN32)
target_sources(openmw-iniimporter PRIVATE ${CMAKE_SOURCE_DIR}/files/windows/other-apps.manifest)
endif()
if (WIN32)
INSTALL(TARGETS openmw-iniimporter RUNTIME DESTINATION ".")
endif(WIN32)

View file

@ -20,6 +20,10 @@ target_link_libraries(openmw-navmeshtool-lib
components
)
if (WIN32)
target_sources(openmw-navmeshtool PRIVATE ${CMAKE_SOURCE_DIR}/files/windows/other-apps.manifest)
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-navmeshtool PRIVATE --coverage)
target_link_libraries(openmw-navmeshtool gcov)

View file

@ -12,6 +12,10 @@ target_link_libraries(niftest
components
)
if (WIN32)
target_sources(niftest PRIVATE ${CMAKE_SOURCE_DIR}/files/windows/other-apps.manifest)
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(niftest PRIVATE --coverage)
target_link_libraries(niftest gcov)

View file

@ -247,7 +247,7 @@ target_link_libraries(openmw-cs-lib
target_link_libraries(openmw-cs-lib Qt::Widgets Qt::Core Qt::Network Qt::OpenGL Qt::OpenGLWidgets Qt::Svg)
if (WIN32)
target_sources(openmw-cs PRIVATE ${CMAKE_SOURCE_DIR}/files/windows/openmw-cs.exe.manifest)
target_sources(openmw-cs PRIVATE ${CMAKE_SOURCE_DIR}/files/windows/other-apps.manifest)
endif()
if (WIN32 AND BUILD_OPENCS)

View file

@ -17,6 +17,10 @@ target_link_libraries(openmw-cs-tests PRIVATE
GMock::GMock
)
if (WIN32)
target_sources(openmw-cs-tests PRIVATE ${CMAKE_SOURCE_DIR}/files/windows/other-apps.manifest)
endif()
if (UNIX AND NOT APPLE)
target_link_libraries(openmw-cs-tests PRIVATE ${CMAKE_THREAD_LIBS_INIT})
endif()

View file

@ -35,6 +35,10 @@ if (UNIX AND NOT APPLE)
target_link_libraries(openmw-tests ${CMAKE_THREAD_LIBS_INIT})
endif()
if (WIN32)
target_sources(openmw-tests PRIVATE ${CMAKE_SOURCE_DIR}/files/windows/other-apps.manifest)
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-tests PRIVATE --coverage)
target_link_libraries(openmw-tests gcov)

View file

@ -78,6 +78,10 @@ if (OPENMW_USE_UNSHIELD)
target_link_libraries(openmw-wizard ${LIBUNSHIELD_LIBRARIES})
endif()
if (WIN32)
target_sources(openmw-wizard PRIVATE ${CMAKE_SOURCE_DIR}/files/windows/other-apps.manifest)
endif()
if(DPKG_PROGRAM)
INSTALL(TARGETS openmw-wizard RUNTIME DESTINATION games COMPONENT openmw-wizard)
endif()

View file

@ -178,7 +178,7 @@ namespace Crash
{
executablePath.resize(executablePath.size() + MAX_PATH);
copied = GetModuleFileNameW(nullptr, executablePath.data(), static_cast<DWORD>(executablePath.size()));
} while (copied >= executablePath.size());
} while (GetLastError() == ERROR_INSUFFICIENT_BUFFER);
executablePath.resize(copied);
writePathToShm(mShm->mStartup.mDumpDirectoryPath, dumpPath);

View file

@ -275,9 +275,6 @@ namespace Crash
return;
}
if (utf16Path.length() > MAX_PATH)
utf16Path = LR"(\\?\)" + utf16Path;
HANDLE hCrashLog = CreateFileW(utf16Path.c_str(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, nullptr);
if (hCrashLog == NULL || hCrashLog == INVALID_HANDLE_VALUE)

View file

@ -10,8 +10,9 @@
</security>
</trustInfo>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings xmlns:ws="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<ws:dpiAware>True</ws:dpiAware>
<windowsSettings xmlns:ws="http://schemas.microsoft.com/SMI/2005/WindowsSettings" xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
<ws:dpiAware>true</ws:dpiAware>
<ws2:longPathAware>true</ws2:longPathAware>
</windowsSettings>
</application>
</assembly>

View file

@ -4,6 +4,7 @@
<asmv3:windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>