File: paths.patch

package info (click to toggle)
primrose 6%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 5,300 kB
  • ctags: 3,385
  • sloc: cpp: 27,318; php: 765; ansic: 636; objc: 272; sh: 136; makefile: 95; perl: 67
file content (47 lines) | stat: -rw-r--r-- 1,339 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Author: Paul Wise <pabs@debian.org>
Description: Allow Linux distros to specify an absolute path to the graphics and use ~/.primrose for settings.
Forwarded: http://sf.net/support/tracker.php?aid=2740890
--- a/tilePlacementGames/game1/gameSource/common.cpp
+++ b/tilePlacementGames/game1/gameSource/common.cpp
@@ -12,7 +12,7 @@
 
 
 Image *readTGA( char *inFileName ) {
-    return readTGA( "graphics", inFileName );
+    return readTGA( DATADIR"graphics", inFileName );
     }
 
 
--- a/tilePlacementGames/game1/gameSource/game.cpp
+++ b/tilePlacementGames/game1/gameSource/game.cpp
@@ -23,6 +23,10 @@
 
 #include <GL/gl.h>
 
+#include <string.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 
 #include "minorGems/util/random/CustomRandomSource.h"
 #include "minorGems/util/SettingsManager.h"
@@ -491,6 +495,19 @@
     #endif
 
 
+    #define SETTINGS "/.primrose"
+    char* home = getenv( "HOME" );
+    size_t len = strlen( home );
+    size_t len2 = sizeof( SETTINGS );
+    char* dir = (char*)malloc( len + len2 );
+    if( dir ){
+        strcpy( dir, home );
+        if( dir[len-1] == '/') strcpy( dir + len - 1, SETTINGS );
+        else strcpy( dir + len, SETTINGS );
+        mkdir( dir, 0777 );
+        SettingsManager::setDirectoryName( dir );
+    }
+
 
 
     // don't use the same salt every time