зеркало из https://github.com/microsoft/STL.git
<filesystem>: create_directories() should throw for empty paths (#1285)
This commit is contained in:
Родитель
554b5d300d
Коммит
d0c089e324
|
@ -3750,6 +3750,11 @@ namespace filesystem {
|
||||||
|
|
||||||
// FUNCTION create_directories
|
// FUNCTION create_directories
|
||||||
inline bool create_directories(const path& _Path, error_code& _Ec) {
|
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
|
_Ec.clear(); // for exception safety
|
||||||
const wstring& _Text = _Path.native();
|
const wstring& _Text = _Path.native();
|
||||||
wstring _Tmp;
|
wstring _Tmp;
|
||||||
|
|
|
@ -3669,6 +3669,11 @@ void test_create_dirs_and_remove_all() {
|
||||||
remove_all(badPath, ec);
|
remove_all(badPath, ec);
|
||||||
EXPECT(good(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
|
// test that normalization isn't done first
|
||||||
auto dots = r / L"a/../b/../c"sv;
|
auto dots = r / L"a/../b/../c"sv;
|
||||||
EXPECT(create_directories(dots));
|
EXPECT(create_directories(dots));
|
||||||
|
|
Загрузка…
Ссылка в новой задаче