Skip to content

Commit c5e8f02

Browse files
committed
[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 59c72a7). Differential Revision: https://reviews.llvm.org/D97090
1 parent 415c67b commit c5e8f02

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

libcxx/src/filesystem/operations.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,8 @@ bool __create_directories(const path& p, error_code* ec) {
10231023
if (ec && *ec) {
10241024
return false;
10251025
}
1026-
}
1026+
} else if (not is_directory(parent_st))
1027+
return err.report(errc::not_a_directory);
10271028
}
10281029
return __create_directory(p, ec);
10291030
}

0 commit comments

Comments
 (0)