From 8db106bf6b1b57ccf35ba40e9c78037b7354e393 Mon Sep 17 00:00:00 2001 From: psychon Date: Sun, 7 Dec 2008 14:18:23 +0000 Subject: [PATCH] Remove our only getcwd() call We now no longer depend on PATH_MAX which is not defined by POSIX. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1286 726aef4b-f618-498e-8847-2d620e286838 --- main.h | 6 ------ znc.cpp | 11 ++++------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/main.h b/main.h index 79db98e0..8d3c78a2 100644 --- a/main.h +++ b/main.h @@ -65,12 +65,6 @@ using std::cout; using std::cerr; using std::endl; -#include -#ifndef PATH_MAX -#define PATH_MAX 1024 -#warning PATH_MAX is undefined -#endif - #include "ZNCString.h" #endif // !_MAIN_H diff --git a/znc.cpp b/znc.cpp index 93b7a58e..0bd206bc 100644 --- a/znc.cpp +++ b/znc.cpp @@ -398,17 +398,14 @@ bool CZNC::IsHostAllowed(const CString& sHostMask) const { } void CZNC::InitDirs(const CString& sArgvPath, const CString& sDataDir) { - char buf[PATH_MAX]; char *home; - if (getcwd(buf, PATH_MAX) == NULL) { - CUtils::PrintError("getcwd() failed, can't read my current dir"); - exit(-1); - } - // If the bin was not ran from the current directory, we need to add that dir onto our cwd CString::size_type uPos = sArgvPath.rfind('/'); - m_sCurPath = (uPos == CString::npos) ? CString(buf) : CDir::ChangeDir(buf, sArgvPath.substr(0, uPos), ""); + if (uPos == CString::npos) + m_sCurPath = "./"; + else + m_sCurPath = CDir::ChangeDir("./", sArgvPath.Left(uPos), ""); // Try to set the user's home dir, default to binpath on failure home = getenv("HOME");