[libcxx-commits] [PATCH] D97619: [libcxx] Map ERROR_BAD_PATHNAME to errc::no_such_file_or_directory on windows

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Feb 27 14:50:31 PST 2021


mstorsjo created this revision.
mstorsjo added a reviewer: libc++.
mstorsjo requested review of this revision.
Herald added a project: libc++.
Herald added 1 blocking reviewer(s): libc++.

Opening a path like \\server (without a trailing share name and path) produces this error, while opening e.g. \\server\share (for a nonexistent server/share) produces ERROR_BAD_NETPATH (which already is mapped).

This happens in some testcases (in fs.op.proximate); as proximate() calls weakly_canonical() on the inputs, weakly_canonical() checks whether the path exists or not. When the error code wasn't recognized (it mapped to errc::invalid_argument), the stat operation wasn't conclusive and weakly_canonical() errored out. With the proper error code mapping, this isn't considered an error, just a nonexistent path, and weakly_canonical() can proceed.

This roughly matches what MS STL does - it doesn't have ERROR_BAD_PATHNAME in its error code mapping table, but it checks for this error code specifically in the return of their correspondence of the stat function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97619

Files:
  libcxx/src/filesystem/operations.cpp


Index: libcxx/src/filesystem/operations.cpp
===================================================================
--- libcxx/src/filesystem/operations.cpp
+++ libcxx/src/filesystem/operations.cpp
@@ -412,6 +412,7 @@
       {ERROR_ACCESS_DENIED, errc::permission_denied},
       {ERROR_ALREADY_EXISTS, errc::file_exists},
       {ERROR_BAD_NETPATH, errc::no_such_file_or_directory},
+      {ERROR_BAD_PATHNAME, errc::no_such_file_or_directory},
       {ERROR_BAD_UNIT, errc::no_such_device},
       {ERROR_BROKEN_PIPE, errc::broken_pipe},
       {ERROR_BUFFER_OVERFLOW, errc::filename_too_long},


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97619.326931.patch
Type: text/x-patch
Size: 593 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210227/1d01f165/attachment.bin>


More information about the libcxx-commits mailing list