Draft: Support Win32 long path #1061
No reviewers
Labels
No labels
announcement
bug
build
CI
dependencies
documentation
duplicate
enhancement
experience feedback
feature request
github_actions
help wanted
install
invalid
Long-term
optimization
portability
question
target-specific
test issue
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-Cyan4973/xxHash!1061
Loading…
Reference in a new issue
No description provided.
Delete branch "win32-long-path"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR fixes #1060.
XSUM_widenStringAsUncPath()incli/xsum_os_specific.c.XSUM_fopen()andXSUM_stat()use this new function.\\?\prefix.wchar_tpath.\\?\prefix.\\?\prefix automatically avoids classic DOS device quirks (e.g.COM1,NUL, etc)\\?\prefix is supported from Windows 2000. But I can't find any source from Microsoft :(tests/windows/00-test-all.batinvokes all tests.tests/windows/build-with-cmake.batbuildsxxhsumwithcmaketests/windows/test-long-path.battests issue #1060.!__!tracks line number.:ERRORroutine uses it to indicate error with line number.For some reason, GH actions for MinGW fails at the following line of the
Makefilegithub.com/Cyan4973/xxHash@fb93aa4c41/Makefile (L207)Error log
I can't reproduce above error in my local msys environment. But here is a different issue from my local environment:
Is this line fine?
github.com/Cyan4973/xxHash@7aee8d0a34/tests/collisions/main.c (L772)Allocation size of
hashCandidatesistableSize.But size for
realloc()isnbCandidates * hashByteSize.Since
nbCandidates < maxNbH, argument ofrelloc()is always less than its original allocation size.It means
realloc()may or may not reallocate (move) its memory region (or not).Therefore, after this
realloc(), we should not usehashCandidates.Also, when I put
printf("%p\n", hashCandidates)for debug, gcc-15 reports the following warning/error.This is great but also I think that Windows requires that there specifically be a manifest in the exe file. Looking into it, I think that we can simply make a file called xxhsum.manifest alongside the xxhsum.c and then cmake will automatically pick that up and link it in: https://cmake.org/cmake/help/v3.4/release/3.4.html#other
Suggested xxhsum.manifest:
@29039 While a manifest file is convenient, my goal is to provide broader compatibility.
For example, I’d like to support “bad” Win32 filenames such as
my_file.(filename with a trailing period). Since Linux/WSL (and NTFS) accepts this as a valid filename, broader compatibility could benefit other users as well. (My current implementation is incorrect, so it doesn’t work yet.)Please also note that this patch works correctly even without a manifest file.
WIP. But now this PR supports long-path, UNC path and trailing period. e.g.
my_trailing_period_file.tests/windows/00-test-all.batbuilds and tests all.TODO:
pathcch.libto simplifiy the code. Though it's only supported Windows8+ or Windows Server 2012+.#pragma comment(lib)Added cmake option
XXHASH_WIN_TARGET_WIN10for MinGW / cross-compile environment.XXHASH_WIN_TARGET_WIN10to cmake.When cmake uses
MSVC, it automatically host environment is Windows 10+ or not.But in the MinGW/MSYS environment, I don't know how to detect it.
Therefore, I added expcilit option for it.
This switch enables long-path code via preprocessor macro
XXHSUM_WIN32_LONGPATH.PATHCCH_DO_NOT_NORMALIZE_SEGMENTS(support trailing period and space) andPATHCCH_ENSURE_IS_EXTENDED_LENGTH_PATH(ensure\\?\prefix) are implemented since Windows 10 RS2 1703 as operation system DLL and its SDK. Unfortunately, earlier version of Windows just ignore these flags.Therefore, its result depends on Win10 version. (
xxhsum my_file.works fine with Win10RS2>, but earlier versions of Win10 reports error "file not found")So we need to check runtime Windows version for it. But it may be over-engineering for this small utility. Possible solutions are:
Sorry, just noticed this question:
I think that's reasonable
@Cyan4973 , thanks. I forgot to add
@to the question 😅I really like the extensive test suite delivered with this patch.
Great PR @t-mat !
This PR is still tagged as "Draft".
But at a quick glance, it already looks pretty clean.
So at which stage is it ?
Still some work to do ? Or ready for review and merge ?
cc @t-mat
Thanks @t-mat !
This PR has been integrated into #1147
Pull request closed