;
}
-// Return whether `path` is a full path.
-inline bool
-is_full_path(nonstd::string_view path)
-{
-#ifdef _WIN32
- if (path.find('\\') != nonstd::string_view::npos) {
- return true;
- }
-#endif
- return path.find('/') != nonstd::string_view::npos;
-}
-
// Return whether `path` represents a precompiled header (see "Precompiled
// Headers" in GCC docs).
bool is_precompiled_header(nonstd::string_view path);
: ctx.orig_args[compiler_pos]);
const std::string resolved_compiler =
- Util::is_full_path(compiler)
+ util::is_full_path(compiler)
? compiler
: find_executable_function(ctx, compiler, CCACHE_NAME);
// Return whether `path` is absolute.
bool is_absolute_path(nonstd::string_view path);
+// Return whether `path` includes at least one directory separator.
+inline bool
+is_full_path(nonstd::string_view path)
+{
+#ifdef _WIN32
+ if (path.find('\\') != nonstd::string_view::npos) {
+ return true;
+ }
+#endif
+ return path.find('/') != nonstd::string_view::npos;
+}
+
// Split a list of paths (such as the content of $PATH on Unix platforms or
// %PATH% on Windows platforms) into paths.
std::vector<std::string> split_path_list(nonstd::string_view path_list);
CHECK(!util::is_absolute_path("foo/fie"));
}
+TEST_CASE("util::is_absolute_path")
+{
+ CHECK(!util::is_full_path(""));
+ CHECK(!util::is_full_path("foo"));
+ CHECK(util::is_full_path("/foo"));
+ CHECK(util::is_full_path("foo/"));
+ CHECK(util::is_full_path("foo/bar"));
+#ifdef _WIN32
+ CHECK(util::is_full_path("foo\\bar"));
+#else
+ CHECK(!util::is_full_path("foo\\bar"));
+#endif
+}
+
TEST_CASE("util::split_path_list")
{
CHECK(util::split_path_list("").empty());