From 920f61414e4eedba33a75fd4c941c06bf17f26a9 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 2 Jun 2007 13:42:55 +0000 Subject: Specific windows code for getting the full path to the exe git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7209 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/configreader.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/configreader.cpp b/src/configreader.cpp index d7a456fdf..11fd7f8c7 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -1614,7 +1614,18 @@ bool ServerConfig::DirValid(const char* dirandfile) std::string ServerConfig::GetFullProgDir() { char buffer[PATH_MAX+1]; - +#ifdef WINDOWS + /* Windows has specific api calls to get the exe path that never fail. + * For once, windows has something of use, compared to the POSIX code + * for this, this is positively neato. + */ + if (GetModuleFileName(NULL, buffer, MAX_PATH)) + { + std::string fullpath = buffer; + std::string::size_type n = fullpath.rfind("\\inspircd.exe"); + return std::string(fullpath, 0, n); + } +#else // Get the current working directory if (getcwd(buffer, PATH_MAX)) { @@ -1631,7 +1642,7 @@ std::string ServerConfig::GetFullProgDir() std::string::size_type n = fullpath.rfind("/inspircd"); return std::string(fullpath, 0, n); } - +#endif return "/"; } -- cgit v1.2.3