openbsd-ports/games/vodovod/patches/patch-config_cpp
simon c260705a23 fix config loading, adjust highscore location, use PATH_MAX,
respect CXXFLAGS, pass PREFIX instead of LOCALBASE and also
set group and modes in plist

noticed by & looks ok to steven@
2007-07-07 10:40:48 +00:00

53 lines
1.5 KiB
Plaintext

$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 <fstream>
#include <sstream>
#include "config.h"
+#include <stdlib.h>
+#include <stdio.h>
//------------------------------------------------------------------------------
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;