Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions stl/inc/filesystem
Original file line number Diff line number Diff line change
Expand Up @@ -3750,6 +3750,11 @@ namespace filesystem {

// FUNCTION create_directories
inline bool create_directories(const path& _Path, error_code& _Ec) {
if (_Path.empty()) {
_Ec = _Make_ec(__std_win_error::_Path_not_found);
return false;
}

_Ec.clear(); // for exception safety
const wstring& _Text = _Path.native();
wstring _Tmp;
Expand Down
5 changes: 5 additions & 0 deletions tests/std/tests/P0218R1_filesystem/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3669,6 +3669,11 @@ void test_create_dirs_and_remove_all() {
remove_all(badPath, ec);
EXPECT(good(ec));

// test GH-1283 create_directories() should throw for empty paths
EXPECT(throws_filesystem_error([] { create_directories(path{}); }, "create_directories", path{}));
EXPECT(create_directories(path{}, ec) == false);
EXPECT(bad(ec));

// test that normalization isn't done first
auto dots = r / L"a/../b/../c"sv;
EXPECT(create_directories(dots));
Expand Down