if (not status_known(parent_st))
return err.report(m_ec);
if (not exists(parent_st)) {
+ if (parent == p)
+ return err.report(errc::invalid_argument);
__create_directories(parent, ec);
if (ec && *ec) {
return false;
TEST_CHECK(!exists(dir));
}
+#ifdef _WIN32
+TEST_CASE(nonexistent_root)
+{
+ std::error_code ec = GetTestEC();
+ // If Q:\ doesn't exist, create_directories would try to recurse upwards
+ // to parent_path() until it finds a directory that does exist. As the
+ // whole path is the root name, parent_path() returns itself, and it
+ // would recurse indefinitely, unless the recursion is broken.
+ if (!exists("Q:\\"))
+ TEST_CHECK(fs::create_directories("Q:\\", ec) == false);
+ TEST_CHECK(fs::create_directories("\\\\nonexistentserver", ec) == false);
+}
+#endif
+
TEST_SUITE_END()