From c6e8fe8125f8900f3019716aa1cfbf18ff8264bd Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 28 Mar 2020 07:15:16 +0100 Subject: Add support for absolute paths in include_dirs config --- src/FileUtil.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/FileUtil.cpp') diff --git a/src/FileUtil.cpp b/src/FileUtil.cpp index a03161f..1fd86d6 100644 --- a/src/FileUtil.cpp +++ b/src/FileUtil.cpp @@ -178,6 +178,27 @@ namespace sibs } #endif +#if OS_FAMILY == OS_FAMILY_POSIX + bool isPathAbsolute(const std::string &path) + { + return !path.empty() && path[0] == '/'; + } +#else + static bool isAlpha(char c) + { + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); + } + + bool isPathAbsolute(const std::string &path) + { + if(path.size() >= 3 && isAlpha(path[0]) && path[1] == ':' && (path[2] == '\\' || path[2] == '/')) + return true; + else if(path.size() >= 4 && memcmp(path.data(), "\\\\?\\", 4) == 0) + return true; + return false; + } +#endif + // TODO: Handle failure (directory doesn't exist, no permission etc) void walkDir(const _tinydir_char_t *directory, FileWalkCallbackFunc callbackFunc) { -- cgit v1.2.3