File: dotfile.patch

package info (click to toggle)
mu-cade 0.11.dfsg1-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid
  • size: 7,596 kB
  • sloc: xml: 403; makefile: 28
file content (88 lines) | stat: -rw-r--r-- 2,810 bytes parent folder | download | duplicates (6)
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
# Copyright (C) 2007  Peter De Wachter <pdewacht@gmail.com>
# Distributed under the same license as the game. See debian/copyright.

Index: mu-cade_0.11.dfsg1/src/abagames/mcd/prefmanager.d
===================================================================
--- mu-cade_0.11.dfsg1.orig/src/abagames/mcd/prefmanager.d	2007-08-26 23:02:41.000000000 +0200
+++ mu-cade_0.11.dfsg1/src/abagames/mcd/prefmanager.d	2007-08-26 23:11:26.000000000 +0200
@@ -6,6 +6,9 @@
 module abagames.mcd.prefmanager;
 
 private import std.stream;
+private import std.string;
+private import std.file;
+private import std.c.stdlib;
 private import abagames.util.prefmanager;
 
 /**
@@ -21,11 +24,23 @@
     _prefData = new PrefData;
   }
 
+  public static char[] pref_dir() {
+    char * home = getenv("HOME");
+    if (home is null)
+      throw new Error("HOME environment variable undefined");
+    char[] dir = std.string.toString(home) ~ "/.mu-cade";
+    try {
+      mkdir(dir);
+    } catch (FileException e) {
+    }
+    return dir;
+  }
+
   public void load() {
     auto File fd = new File;
     try {
       int ver;
-      fd.open(PREF_FILE_NAME);
+      fd.open(pref_dir() ~ "/" ~ PREF_FILE_NAME);
       fd.read(ver);
       if (ver != VERSION_NUM)
         throw new Error("Wrong version num");
@@ -41,7 +56,7 @@
 
   public void save() {
     auto File fd = new File;
-    fd.create(PREF_FILE_NAME);
+    fd.create(pref_dir ~ "/" ~ PREF_FILE_NAME);
     fd.write(VERSION_NUM);
     _prefData.save(fd);
     fd.close();
Index: mu-cade_0.11.dfsg1/src/abagames/mcd/replay.d
===================================================================
--- mu-cade_0.11.dfsg1.orig/src/abagames/mcd/replay.d	2007-08-26 23:02:41.000000000 +0200
+++ mu-cade_0.11.dfsg1/src/abagames/mcd/replay.d	2007-08-26 23:02:46.000000000 +0200
@@ -9,13 +9,13 @@
 private import abagames.util.sdl.recordableinput;
 private import abagames.util.sdl.twinstickpad;
 private import abagames.mcd.gamemanager;
+private import abagames.mcd.prefmanager;
 
 /**
  * Save/Load a replay data.
  */
 public class ReplayData {
  public:
-  static const char[] dir = "replay";
   static const int VERSION_NUM = 10;
   InputRecord!(TwinStickPadState) twinStickPadInputRecord;
   long seed;
@@ -25,7 +25,7 @@
 
   public void save(char[] fileName) {
     auto File fd = new File;
-    fd.create(dir ~ "/" ~ fileName);
+    fd.create(PrefManager.pref_dir() ~ "/" ~ fileName);
     fd.write(VERSION_NUM);
     fd.write(seed);
     fd.write(score);
@@ -36,7 +36,7 @@
 
   public void load(char[] fileName) {
     auto File fd = new File;
-    fd.open(dir ~ "/" ~ fileName);
+    fd.open(PrefManager.pref_dir() ~ "/" ~ fileName);
     int ver;
     fd.read(ver);
     if (ver != VERSION_NUM)