$OpenBSD: patch-config_cpp,v 1.2 2007/07/07 10:40:48 simon Exp $ --- config.cpp.orig Sun Jun 3 13:09:24 2007 +++ config.cpp Fri Jul 6 10:28:01 2007 @@ -22,6 +22,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, #include #include #include "config.h" +#include +#include //------------------------------------------------------------------------------ using namespace std; //----------------------------------------------------------------------------- @@ -155,7 +157,18 @@ Config::~Config() //----------------------------------------------------------------------------- bool Config::save() { - std::ofstream file("vodovod.conf"); + const char *home; + char path[PATH_MAX]; + int n; + + if ((home = getenv("HOME")) == NULL) + false; + + if ((n = snprintf(path, PATH_MAX, "%s/.vodovod.conf", home) >= PATH_MAX) || + n <= 0) + false; + + std::ofstream file(path); if (!file) return false; @@ -171,7 +184,18 @@ bool Config::save() // this gets called from main() so we're sure config.ini is in the right place bool Config::load() { - std::ifstream file("vodovod.conf"); + const char *home; + char path[PATH_MAX]; + int n; + + if ((home = getenv("HOME")) == NULL) + false; + + if ((n = snprintf(path, PATH_MAX, "%s/.vodovod.conf", home) >= PATH_MAX) || + n <= 0) + false; + + std::ifstream file(path); if (!file) return false;