[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 59c72a7012).

Differential Revision: https://reviews.llvm.org/D97090
This commit is contained in:
Martin Storsjö 2020-12-18 13:34:35 +02:00
parent 415c67ba4c
commit c5e8f024dc
1 changed files with 2 additions and 1 deletions

View File

@ -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);
}