From 293625c17b992303ddd175b2f96ec1c96751a7f4 Mon Sep 17 00:00:00 2001 From: Jean Flach Date: Mon, 24 Apr 2017 15:39:21 +0200 Subject: [PATCH] Fix absolute include paths for windows fixes #5168 --- lib/config/configcompiler.cpp | 13 ++++++++----- lib/config/configcompiler.hpp | 8 ++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/config/configcompiler.cpp b/lib/config/configcompiler.cpp index fa5c90d37..6b5f3a3ca 100644 --- a/lib/config/configcompiler.cpp +++ b/lib/config/configcompiler.cpp @@ -26,6 +26,10 @@ #include "base/exception.hpp" #include +#ifdef _WIN32 +#include "Shlwapi.h" +#endif /* _WIN32 */ + using namespace icinga; std::vector ConfigCompiler::m_IncludeSearchDirs; @@ -135,7 +139,7 @@ Expression *ConfigCompiler::HandleInclude(const String& relativeBase, const Stri { String upath; - if (search || (path.GetLength() > 0 && path[0] == '/')) + if (search || (IsAbsolutePath(path))) upath = path; else upath = relativeBase + "/" + path; @@ -179,7 +183,7 @@ Expression *ConfigCompiler::HandleIncludeRecursive(const String& relativeBase, c { String ppath; - if (path.GetLength() > 0 && path[0] == '/') + if (IsAbsolutePath(path)) ppath = path; else ppath = relativeBase + "/" + path; @@ -198,7 +202,7 @@ void ConfigCompiler::HandleIncludeZone(const String& relativeBase, const String& String ppath; - if (path.GetLength() > 0 && path[0] == '/') + if (IsAbsolutePath(path)) ppath = path; else ppath = relativeBase + "/" + path; @@ -223,7 +227,7 @@ Expression *ConfigCompiler::HandleIncludeZones(const String& relativeBase, const String ppath; String newRelativeBase = relativeBase; - if (path.GetLength() > 0 && path[0] == '/') + if (IsAbsolutePath(path)) ppath = path; else { ppath = relativeBase + "/" + path; @@ -350,4 +354,3 @@ bool ConfigCompiler::HasZoneConfigAuthority(const String& zoneName) return !empty; } - diff --git a/lib/config/configcompiler.hpp b/lib/config/configcompiler.hpp index d8812dd1c..472fa2330 100644 --- a/lib/config/configcompiler.hpp +++ b/lib/config/configcompiler.hpp @@ -127,6 +127,14 @@ public: static bool HasZoneConfigAuthority(const String& zoneName); + static inline bool IsAbsolutePath(const String& path) { +#ifndef _WIN32 + return (path.GetLength() > 0 && path[0] == '/'); +#else + return !PathIsRelative(path.CStr()); +#endif /* _WIN32 */ + } + private: boost::promise > m_Promise;