return k_dev_null_path;
}
+fs::path
+lexically_normal(const fs::path& path)
+{
+ auto result = path.lexically_normal();
+ return result.has_filename() ? result : result.parent_path();
+}
+
fs::path
make_relative_path(const fs::path& actual_cwd,
const fs::path& apparent_cwd,
const char* get_dev_null_path();
+// Return lexically normal `path` without trailing slash.
+std::filesystem::path lexically_normal(const std::filesystem::path& path);
+
// Return whether `path` is /dev/null or (on Windows) NUL.
bool is_dev_null_path(const std::filesystem::path& path);
#endif
}
+TEST_CASE("util::lexically_normal")
+{
+ CHECK(util::lexically_normal("") == "");
+ CHECK(util::lexically_normal("/") == "/");
+ CHECK(util::lexically_normal("x") == "x");
+ CHECK(util::lexically_normal("x/../y") == "y");
+ CHECK(util::lexically_normal("x/") == "x");
+ CHECK(util::lexically_normal("x/.") == "x");
+}
+
TEST_CASE("util::make_relative_path")
{
using util::make_relative_path;