File: abs_path.patch

package info (click to toggle)
between 6%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,532 kB
  • sloc: cpp: 28,110; php: 718; ansic: 638; objc: 245; sh: 236; makefile: 97; perl: 67
file content (100 lines) | stat: -rw-r--r-- 3,476 bytes parent folder | download | duplicates (3)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Description: Use absolute paths to the installed data files.
Author: Paul Wise <pabs@debian.org>
Bug: http://sf.net/support/tracker.php?aid=2672133
--- a/game7/gameSource/common.cpp
+++ b/game7/gameSource/common.cpp
@@ -12,7 +12,7 @@
 
 
 Image *readTGA( const char *inFileName ) {
-    return readTGA( "graphics", inFileName );
+    return readTGA( DATADIR"graphics", inFileName );
     }
 
 
--- a/game7/gameSource/musicPlayer.cpp
+++ b/game7/gameSource/musicPlayer.cpp
@@ -425,7 +425,7 @@
 
 void loadMusicImage( const char *inTGAFileName ) {
         
-    musicImage = readTGA( "music", inTGAFileName );
+    musicImage = readTGA( DATADIR"music", inTGAFileName );
 
     w = musicImage->getWidth();
     h = musicImage->getHeight();
--- a/minorGems/util/SettingsManager.cpp
+++ b/minorGems/util/SettingsManager.cpp
@@ -379,7 +379,7 @@
 
 
 SettingsManagerStaticMembers::SettingsManagerStaticMembers()
-    : mDirectoryName( stringDuplicate( "settings" ) ),
+    : mDirectoryName( stringDuplicate( ETCDIR ) ),
       mHashSalt( stringDuplicate( "default_salt" ) ) {
     
     }
--- a/game7/gameSource/Client.cpp
+++ b/game7/gameSource/Client.cpp
@@ -6,6 +6,8 @@
 #include "minorGems/util/SettingsManager.h"
 
 #include <time.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 
 
 char *Client::sServerURL = NULL;
@@ -254,7 +256,21 @@
                 
                     mPlayerID = stringDuplicate( returnedID );
 
-                    SettingsManager::setSetting( "playerID", mPlayerID );
+                    #define SETTINGS "/.between"
+                    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 );
+                      char* dirName = SettingsManager::getDirectoryName();
+                      SettingsManager::setDirectoryName( dir );
+                      SettingsManager::setSetting( "playerID", mPlayerID );
+                      SettingsManager::setDirectoryName( dirName );
+                    } else SettingsManager::setSetting( "playerID", mPlayerID );
                     }
                 else {
                     resultWellFormatted = false;
--- a/minorGems/util/TranslationManager.cpp
+++ b/minorGems/util/TranslationManager.cpp
@@ -162,7 +162,7 @@
       mNaturalLanguageStrings( NULL ) {
 
     // default
-    setDirectoryAndLanguage( "languages", "English" );
+    setDirectoryAndLanguage( DATADIR"languages", "English" );
     }
 
 
--- a/game7/gameSource/game.cpp
+++ b/game7/gameSource/game.cpp
@@ -1411,7 +1411,7 @@
 void GameSceneHandler::initFromFiles() {
     
     // translation language
-    File languageNameFile( NULL, "language.txt" );
+    File languageNameFile( new Path(DATADIR), "language.txt" );
 
     if( languageNameFile.exists() ) {
         char *languageNameText = languageNameFile.readFileContents();
@@ -1424,6 +1424,7 @@
         if( numTokens > 0 ) {
             char *languageName = *( tokens->getElement( 0 ) );
         
+            TranslationManager::setDirectoryName( DATADIR "/languages" );
             TranslationManager::setLanguage( languageName );
             }
         else {