-// Copyright (C) 2016-2021 Free Software Foundation, Inc.
+// Copyright (C) 2016-2024 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }
b = create_directory(p);
VERIFY( !b );
+ auto f = p/"file";
+ std::ofstream{f} << "create file";
+ b = create_directory(f, ec);
+ VERIFY( ec == std::errc::file_exists );
+ VERIFY( !b );
+ try
+ {
+ create_directory(f);
+ VERIFY( false );
+ }
+ catch (const fs::filesystem_error& e)
+ {
+ VERIFY( e.code() == std::errc::file_exists );
+ VERIFY( e.path1() == f );
+ }
+
+#ifndef NO_SYMLINKS
+ // PR libstdc++/101510 create_directory on an existing symlink to a directory
+ fs::create_directory(p/"dir");
+ auto link = p/"link";
+ fs::create_directory_symlink("dir", link);
+ ec = bad_ec;
+ b = fs::create_directory(link, ec);
+ VERIFY( !b );
+ VERIFY( !ec );
+ b = fs::create_directory(link);
+ VERIFY( !b );
+#endif
+
remove_all(p, ec);
}