[libcxx-commits] [libcxx] c5e8f02 - [libcxx] Explicitly return the expected error code in create_directories if the parent isn't a directory

Martin Storsjö via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 2 12:24:20 PST 2021


Author: Martin Storsjö
Date: 2021-03-02T22:21:29+02:00
New Revision: c5e8f024dca9ddf6d14253fe2fcc5c4956de2d3c

URL: https://github.com/llvm/llvm-project/commit/c5e8f024dca9ddf6d14253fe2fcc5c4956de2d3c
DIFF: https://github.com/llvm/llvm-project/commit/c5e8f024dca9ddf6d14253fe2fcc5c4956de2d3c.diff

LOG: [libcxx] Explicitly return the expected error code in create_directories if the parent isn't a directory

On windows, going ahead and actually trying to create the directory
doesn't return an error code that maps to
std::errc::not_a_directory in this case.

This fixes two cases of
    TEST_CHECK(ErrorIs(ec, std::errc::not_a_directory))
in filesystems/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp
for windows (in testcases added in 59c72a70121567f7aee347e96b4ac8f3cfe9f4b2).

Differential Revision: https://reviews.llvm.org/D97090

Added: 
    

Modified: 
    libcxx/src/filesystem/operations.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp
index 06efb722e054..f1121686b4a8 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -1023,7 +1023,8 @@ bool __create_directories(const path& p, error_code* ec) {
       if (ec && *ec) {
         return false;
       }
-    }
+    } else if (not is_directory(parent_st))
+      return err.report(errc::not_a_directory);
   }
   return __create_directory(p, ec);
 }


        


More information about the libcxx-commits mailing list