updated on Wed Jan 11 00:07:16 UTC 2012
[aur-mirror.git] / vodovod / user_files.patch
blobef2557990fed4938717fdd0e308a7e09cf4db790
1 --- vodovod-1.05.orig/config.cpp
2 +++ vodovod-1.05/config.cpp
3 @@ -21,6 +21,9 @@
4 #include <string>
5 #include <fstream>
6 #include <sstream>
7 +#include <stdlib.h>
8 +#include <stdio.h>
9 +#include <sys/stat.h>
10 #include "config.h"
11 //------------------------------------------------------------------------------
12 using namespace std;
13 @@ -155,7 +158,19 @@
14 //-----------------------------------------------------------------------------
15 bool Config::save()
17 - std::ofstream file("vodovod.conf");
18 + char vodovod_conf[PATH_MAX] = "vodovod.conf";
20 +#ifndef _WIN32
21 + char *home = getenv("HOME");
22 + if (home != NULL)
23 + {
24 + snprintf(vodovod_conf, sizeof(vodovod_conf), "%s/.vodovod", home);
25 + mkdir(vodovod_conf, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
26 + }
27 + strncat(vodovod_conf, "/vodovod.conf", sizeof(vodovod_conf));
28 +#endif
30 + std::ofstream file(vodovod_conf);
31 if (!file)
32 return false;
34 @@ -171,7 +186,15 @@
35 // this gets called from main() so we're sure config.ini is in the right place
36 bool Config::load()
38 - std::ifstream file("vodovod.conf");
39 + char vodovod_conf[PATH_MAX] = "vodovod.conf";
41 +#ifndef _WIN32
42 + char *home = getenv("HOME");
43 + if (home != NULL)
44 + snprintf(vodovod_conf, sizeof(vodovod_conf), "%s/.vodovod/vodovod.conf", home);
45 +#endif
47 + std::ifstream file(vodovod_conf);
48 if (!file)
49 return false;
51 --- vodovod-1.05.orig/hiscore.cpp
52 +++ vodovod-1.05/hiscore.cpp
53 @@ -17,7 +17,9 @@
54 along with Vodovod in file COPYING; if not, write to the Free Software
55 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
56 -----------------------------------------------------------------------------*/
57 -#include "stdio.h"
58 +#include <stdio.h>
59 +#include <stdlib.h>
60 +#include <sys/stat.h>
61 #include "hiscore.h"
62 //-----------------------------------------------------------------------------
63 HiScores &hiScores()
64 @@ -102,9 +104,21 @@
65 //-----------------------------------------------------------------------------
66 HiScores::~HiScores()
68 + char hiscore_dat[PATH_MAX] = "hiscore.dat";
70 +#ifndef _WIN32
71 + char *home = getenv("HOME");
72 + if (home != NULL)
73 + {
74 + snprintf(hiscore_dat, sizeof(hiscore_dat), "%s/.vodovod", home);
75 + mkdir(hiscore_dat, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
76 + }
77 + strncat(hiscore_dat, "/hiscore.dat", sizeof(hiscore_dat));
78 +#endif
80 // save to file
81 // format: NAME#POINTS#SWAPS#
82 - FILE *fp = fopen("hiscore.dat", "w+");
83 + FILE *fp = fopen(hiscore_dat, "w+");
84 if (fp)
86 for (iterator it = begin(); it != end(); ++it)