https://bugs.winehq.org/show_bug.cgi?id=51869
Bug ID: 51869 Summary: ReplaceFileW/A does not work with Unix-style paths Product: Wine Version: 6.0.1 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: kernel32 Assignee: wine-bugs@winehq.org Reporter: quyse0@gmail.com Distribution: ---
Created attachment 70784 --> https://bugs.winehq.org/attachment.cgi?id=70784 Test log
It seems ReplaceFile function does not handle Unix-style paths correctly. I tested calls like:
ReplaceFileW(L"abc/def/12.txt", L"abc/def/34.txt", NULL, 0, NULL, NULL)); ReplaceFileW(L"abc\def\56.txt", L"abc\def\78.txt", NULL, 0, NULL, NULL));
Under Wine, first call fails, second one succeeds. The relevant part of WINEDEBUG=+all log is in the attachment. On Windows, both calls succeed.
I attempted to look at Wine code, and it seems the problem is that ReplaceFileW implementation tries to get directory name of replaced file using PathRemoveFileSpecW, which only handles backslashes. On Windows, PathRemoveFileSpecW also works with backslashes only, but ReplaceFileW still works correctly with Unix-style paths.
For context, I am trying to run a proprietary compiler toolchain under Wine, and my script passes Unix-style paths to it, which is I believe a common practice for cross-platform build scripts. The same script works fine on Windows, but fails under Wine.
I mostly use Wine stable (6.0.1), but tested that Wine 6.19 has the same behavior.
https://bugs.winehq.org/show_bug.cgi?id=51869
--- Comment #1 from Alexander Bich quyse0@gmail.com --- Created attachment 70785 --> https://bugs.winehq.org/attachment.cgi?id=70785 simple patch
Attached simple patch. It's not great i.e. performs RtlDosPathNameToNtPathName_U conversion twice, but it fixed the issue for me.