// Return whether `path` is absolute.
bool is_absolute_path(nonstd::string_view path);
+// Return whether `ch` is a directory separator, i.e. '/' on POSIX systems and
+// '/' or '\\' on Windows systems.
+inline bool
+is_dir_separator(char ch)
+{
+ return ch == '/'
+#ifdef _WIN32
+ || ch == '\\'
+#endif
+ ;
+}
+
// Normalize absolute path `path`, not taking symlinks into account.
//
// Normalization here means syntactically removing redundant slashes and
CHECK(!Util::is_absolute_path("foo/fie"));
}
+TEST_CASE("Util::is_dir_separator")
+{
+ CHECK(!Util::is_dir_separator('x'));
+ CHECK(Util::is_dir_separator('/'));
+#ifdef _WIN32
+ CHECK(Util::is_dir_separator('\\'));
+#else
+ CHECK(!Util::is_dir_separator('\\'));
+#endif
+}
+
TEST_CASE("Util::normalize_absolute_path")
{
CHECK(Util::normalize_absolute_path("") == "");