Hello,
The experimental filesystem library is failiing for my project, and from what I can gather, it's caused by _wstat64i32 not correctly handling paths ending with slash. Patch #34 fixed failure of stat & wstat when the path ends with a slash, however _wstat64i32 etc were not fixed. The current implementation of std::experimental::filesystem uses _wstat to retrieve path status, which is a macro which expands to _wstat64i32. This in turn causes the filesystem library to fail, e.g., create_directories can fail because the call is_directory will fail and return false for the parent directories (which ends with slash).
What are you talking about?
Sorry, I mean https://sourceforge.net/p/mingw-w64/patches/34/
Done for master:
https://sourceforge.net/p/mingw-w64/mingw-w64/ci/32ec57d19d9678f0be7c4ecb2b251dba10d860e6/
The fix looks wrong, it means that
_stat("regular_file/", &buf)will resolve to"regular_file"but a trailing slash should only be valid on a directory. Stripping the slash unconditionally is wrong.A better fix would be to append
"."to the path, so that something ending in a slash is treated as a directory, but that won't work because of https://sourceforge.net/p/mingw-w64/bugs/782/I take it back, on Windows
"regular_file/"is the same path as"regular_file"so stripping the slash is fine, and works consistently with the expected behaviour on the OS.I was foolishly expecting Windows to have sane pathname handling, but I was wrong.
This seems to have been fixed for
_statand_wstatbut not for_wstat64. Is that intentional?ping?
I don't think it is intentional, is this still happening?
I see it with 7.0.0 which includes the fixes for this issue (but only
_statand_wstat), did_wstat64change for 8.0.0?@nixmann I can still reproduce the issue;
stat()errors out on a directory path with trailing slash with-D_FILE_OFFSET_BITS=64.Should we reopen this or do I open a new bug?
Toolchain Version: MinGW x86_64-12.2.0-release-posix-seh-rt_v10-rev0
Last edit: Sundaram Ramaswamy 2022-10-11