aboutsummaryrefslogtreecommitdiff
path: root/libcxx/src/filesystem/operations.cpp
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2021-02-27 16:09:49 +0200
committerMartin Storsjö <martin@martin.st>2021-03-05 10:49:03 +0200
commit29012ce986fcb24175f19317b4e2d119cd8cdbb2 (patch)
treeda6e6b1ee5af152d58f778dd08d847f363a627a1 /libcxx/src/filesystem/operations.cpp
parent99c7b532946508efcf6cd978d86ee24b2a66d096 (diff)
downloadllvm-29012ce986fcb24175f19317b4e2d119cd8cdbb2.zip
llvm-29012ce986fcb24175f19317b4e2d119cd8cdbb2.tar.gz
llvm-29012ce986fcb24175f19317b4e2d119cd8cdbb2.tar.bz2
[libcxx] Map ERROR_BAD_PATHNAME to errc::no_such_file_or_directory on windows
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. Differential Revision: https://reviews.llvm.org/D97619
Diffstat (limited to 'libcxx/src/filesystem/operations.cpp')
-rw-r--r--libcxx/src/filesystem/operations.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp
index 35f6937..a002d0a 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -412,6 +412,7 @@ errc __win_err_to_errc(int err) {
{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},