From 4a91b122211495ce9d4b2f2fd9ff77e38221a885 Mon Sep 17 00:00:00 2001 From: cyberbotx Date: Sun, 23 Aug 2009 21:50:55 +0000 Subject: Really fix running Anope from another directory besides bin, and also fix running it from bin (apparently gdb makes the 0 argument in main() the full path, but outside gdb it's not the full path). git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2463 5417fbe8-f217-4b02-8779-1006273d7864 --- src/main.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/main.c b/src/main.c index 5fcfe3a1c..4ba42f621 100644 --- a/src/main.c +++ b/src/main.c @@ -345,6 +345,8 @@ std::string GetFullProgDir(char *argv0) } services_bin = remainder; + if (services_bin.substr(0, 2) == "./") + services_bin = services_bin.substr(2); std::string fullpath = static_cast(buffer) + "/" + remainder; std::string::size_type n = fullpath.rfind("/" SERVICES_BIN); return std::string(fullpath, 0, n); @@ -390,6 +392,8 @@ int main(int ac, char **av, char **envp) #endif binary_dir = GetFullProgDir(av[0]); + if (binary_dir[binary_dir.size() - 1] == '.') + binary_dir = binary_dir.substr(0, binary_dir.size() - 2); #ifdef _WIN32 std::string::size_type n = binary_dir.rfind("\\"); services_dir = binary_dir.substr(0, n) + "\\data"; -- cgit