]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/configreader.cpp
Change for reverse output of lists, most recent first, for bug #307. Also fix(Oms...
[user/henk/code/inspircd.git] / src / configreader.cpp
index bb22db3b16b75faf598cdf5fb4a8f1698eb3c353..5ec60d1c31beb187cfe0474b0a9bba5226259e8a 100644 (file)
@@ -1602,20 +1602,26 @@ bool ServerConfig::DirValid(const char* dirandfile)
 
 std::string ServerConfig::GetFullProgDir()
 {
-       char buffer[1024];
+       char buffer[PATH_MAX+1];
 
        // Get the current working directory
-       if (getcwd(buffer, 1024) == NULL)
+       if (getcwd(buffer, PATH_MAX))
        {
-               return "";
-       }
+               std::string remainder = this->argv[0];
 
-       if (chdir(buffer) == -1)
-       {
-               return "";
+               /* Does argv[0] start with /? its a full path, use it */
+               if (remainder[0] == '/')
+               {
+                       std::string::size_type n = remainder.rfind("/inspircd");
+                       return std::string(remainder, 0, n);
+               }
+
+               std::string fullpath = std::string(buffer) + "/" + remainder;
+               std::string::size_type n = fullpath.rfind("/inspircd");
+               return std::string(fullpath, 0, n);
        }
 
-       return buffer;
+       return "/";
 }
 
 InspIRCd* ServerConfig::GetInstance()