From ae26712ee7fbcb34f88be4261a7b62c1a3da2e7b Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 4 Jun 2007 18:39:22 +0000 Subject: Fix windows issue locating some files relative to the conf dir (namely motd, rules, quotes), See: http://www.inspircd.org/forum/showthread.php?t=989&page=2 git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7231 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/configreader.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/configreader.cpp b/src/configreader.cpp index 729c1b163..76aec8ee5 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -1483,19 +1483,20 @@ bool ServerConfig::ReadFile(file_cache &F, const char* fname) F.clear(); - if (*fname != '/') + if ((*fname != '/') && (*fname != '\\')) { std::string::size_type pos; std::string confpath = ServerInstance->ConfigFileName; - if((pos = confpath.rfind("/")) != std::string::npos) - { - /* Leaves us with just the path */ - std::string newfile = confpath.substr(0, pos) + std::string("/") + fname; - if (!FileExists(newfile.c_str())) - return false; - file = fopen(newfile.c_str(), "r"); + std::string newfile = fname; - } + if ((pos = confpath.rfind("/")) != std::string::npos) + newfile = confpath.substr(0, pos) + std::string("/") + fname; + else if ((pos = confpath.rfind("\\")) != std::string::npos) + newfile = confpath.substr(0, pos) + std::string("\\") + fname; + + if (!FileExists(newfile.c_str())) + return false; + file = fopen(newfile.c_str(), "r"); } else { @@ -1549,7 +1550,7 @@ bool ServerConfig::FileExists(const char* file) char* ServerConfig::CleanFilename(char* name) { char* p = name + strlen(name); - while ((p != name) && (*p != '/')) p--; + while ((p != name) && (*p != '/') && (*p != '\\')) p--; return (p != name ? ++p : p); } -- cgit v1.2.3