summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-06-04 18:39:22 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-06-04 18:39:22 +0000
commitae26712ee7fbcb34f88be4261a7b62c1a3da2e7b (patch)
tree23da3e3289b178cf6b900d24a3c98e12bc5bd6f0
parent75f82deb8706d6fb23f19e2af8301bfe7c9b7693 (diff)
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
-rw-r--r--src/configreader.cpp21
1 files 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);
}