diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-06-02 13:42:55 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-06-02 13:42:55 +0000 |
commit | 920f61414e4eedba33a75fd4c941c06bf17f26a9 (patch) | |
tree | 98be1fce3cd5cbc44ee446f9f5399e80af075cce /src | |
parent | eb334f8c69872cc0de28ffd85b41555f196a23dd (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/configreader.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
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 "/"; } |