Fix absolute include paths for windows

fixes #5168
This commit is contained in:
Jean Flach 2017-04-24 15:39:21 +02:00
parent d7b939d99b
commit 293625c17b
2 changed files with 16 additions and 5 deletions

View File

@ -26,6 +26,10 @@
#include "base/exception.hpp" #include "base/exception.hpp"
#include <fstream> #include <fstream>
#ifdef _WIN32
#include "Shlwapi.h"
#endif /* _WIN32 */
using namespace icinga; using namespace icinga;
std::vector<String> ConfigCompiler::m_IncludeSearchDirs; std::vector<String> ConfigCompiler::m_IncludeSearchDirs;
@ -135,7 +139,7 @@ Expression *ConfigCompiler::HandleInclude(const String& relativeBase, const Stri
{ {
String upath; String upath;
if (search || (path.GetLength() > 0 && path[0] == '/')) if (search || (IsAbsolutePath(path)))
upath = path; upath = path;
else else
upath = relativeBase + "/" + path; upath = relativeBase + "/" + path;
@ -179,7 +183,7 @@ Expression *ConfigCompiler::HandleIncludeRecursive(const String& relativeBase, c
{ {
String ppath; String ppath;
if (path.GetLength() > 0 && path[0] == '/') if (IsAbsolutePath(path))
ppath = path; ppath = path;
else else
ppath = relativeBase + "/" + path; ppath = relativeBase + "/" + path;
@ -198,7 +202,7 @@ void ConfigCompiler::HandleIncludeZone(const String& relativeBase, const String&
String ppath; String ppath;
if (path.GetLength() > 0 && path[0] == '/') if (IsAbsolutePath(path))
ppath = path; ppath = path;
else else
ppath = relativeBase + "/" + path; ppath = relativeBase + "/" + path;
@ -223,7 +227,7 @@ Expression *ConfigCompiler::HandleIncludeZones(const String& relativeBase, const
String ppath; String ppath;
String newRelativeBase = relativeBase; String newRelativeBase = relativeBase;
if (path.GetLength() > 0 && path[0] == '/') if (IsAbsolutePath(path))
ppath = path; ppath = path;
else { else {
ppath = relativeBase + "/" + path; ppath = relativeBase + "/" + path;
@ -350,4 +354,3 @@ bool ConfigCompiler::HasZoneConfigAuthority(const String& zoneName)
return !empty; return !empty;
} }

View File

@ -127,6 +127,14 @@ public:
static bool HasZoneConfigAuthority(const String& zoneName); 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: private:
boost::promise<boost::shared_ptr<Expression> > m_Promise; boost::promise<boost::shared_ptr<Expression> > m_Promise;