~ubuntu-branches/ubuntu/lucid/mupen64plus/lucid-updates

« back to all changes in this revision

Viewing changes to debian/patches/115-xdg-basedir.patch

  • Committer: Bazaar Package Importer
  • Author(s): Sven Eckelmann
  • Date: 2009-09-28 15:23:17 UTC
  • Revision ID: james.westby@ubuntu.com-20090928152317-84y17o8hlh7batmw
Tags: 1.5+dfsg1-5
* debian/patches:
  - Change to dep3 patch tagging guidelines
  - Remove number before patches as order is given by debian/patches/series
  - Add gtk-open-filter.patch, Show files with .n64 and .v64 extension in
    filtered open file dialog (Closes: #546046)
  - Add noexecstack.patch, Don't enable executable stack by default
    (Closes: #547644)
  - Add fix_readpng.patch, Fix crash when loading png due to reordering
    optimizer
  - Add jttl_fix_romclosed.patch, Stop audio processing thread before freeing
    buffers to fix segfault during stop of emulation
  - Add rice_nodebug.patch, Don't enable excessive debug functionality in
    rice_video
  - Add interpreter_x86_fldcw.patch, Correctly set floating point control word
  - Add load-fpr-location.patch, Set register bank location when loading
    savestate

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
From 2492ef7700bb2f1fb787c24d2c54c07d18d92eb5 Mon Sep 17 00:00:00 2001
2
 
From: Sven Eckelmann <sven.eckelmann@gmx.de>
3
 
Date: Mon, 31 Aug 2009 23:29:24 +0200
4
 
Subject: [PATCH] Use XDG Base Directory compliant directories
5
 
 
6
 
The freedesktop standard for basedir[1] defines three different types of
7
 
user directories which mupen64plus uses. They are defined by environment
8
 
variables and in the case if they are absend by well defined standard
9
 
paths.
10
 
 
11
 
 * Data directory ($XDG_DATA_HOME); default: $HOME/.local/share/
12
 
   - save, screenshots, hires_texture, texture_dump
13
 
 * Config directory ($XDG_CONFIG_HOME); default: $HOME/.config/
14
 
   - mupen64plus.conf, configuration files of plugins
15
 
 * Cache directory ($XDG_DATA_HOME); default: $HOME/.cache/
16
 
   - rombrowser.cache and all other files which could be deleted
17
 
     without loosing essential data
18
 
 
19
 
Specific directories for each tool should be created below that base
20
 
directories. libxdg-basedir can be used to find the correct paths
21
 
without caring much about the actual specification.
22
 
 
23
 
The current config dir has to be splitted in these three different
24
 
directories. That also means that plugins have to be informed about that
25
 
dirs. New functions SetDataDir and SetCacheDir have been specified
26
 
inside the API headers and implemented were the plugin would benefit
27
 
from it. This is the case in rice_video for texture_dump and
28
 
hires_texture.
29
 
 
30
 
The user can also override the data and cache directories by the new
31
 
commandline options --datadir and --cachedir.
32
 
 
33
 
As there is no real specification for Windows available the behavior on
34
 
that platform was not changed.
35
 
 
36
 
[1] http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
37
 
 
38
 
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
39
 
---
40
 
 Makefile                      |    3 +-
41
 
 blight_input/Input_1.1.h      |   22 +++++++
42
 
 doc/Audio_1.1.h               |   22 +++++++
43
 
 doc/Audio_1.2.h               |   22 +++++++
44
 
 doc/Graphics_1.3.h            |   22 +++++++
45
 
 doc/Input_1.1.h               |   22 +++++++
46
 
 dummy_audio/Audio_1.1.h       |   22 +++++++
47
 
 dummy_input/Input_1.1.h       |   22 +++++++
48
 
 dummy_video/Graphics_1.3.h    |   22 +++++++
49
 
 glide64/Gfx1.3.h              |   22 +++++++
50
 
 jttl_audio/Audio_1.2.h        |   22 +++++++
51
 
 main/main.c                   |  123 ++++++++++++++++++++++++++++++++++------
52
 
 main/main.h                   |    2 +
53
 
 main/plugin.c                 |   12 ++++-
54
 
 main/plugin.h                 |    2 +-
55
 
 main/romcache.c               |    2 +-
56
 
 pre.mk                        |    9 +++
57
 
 rice_video/Graphics_1.3.h     |   22 +++++++
58
 
 rice_video/TextureFilters.cpp |    8 +-
59
 
 rice_video/Video.cpp          |   80 +++++++++++++++++++++++++-
60
 
 rsp_hle/Audio_1.1.h           |   22 +++++++
61
 
 21 files changed, 474 insertions(+), 31 deletions(-)
62
 
 
63
 
diff --git a/Makefile b/Makefile
64
 
index be81163..dac741e 100644
65
 
--- a/Makefile
66
 
+++ b/Makefile
67
 
@@ -237,8 +237,9 @@ SHARE = $(shell grep CONFIG_PATH config.h | cut -d '"' -f 2)
68
 
 # set primary objects and libraries for all outputs
69
 
 ALL = mupen64plus $(PLUGINS)
70
 
 OBJECTS = $(OBJ_CORE) $(OBJ_DYNAREC) $(OBJ_OPENGL)
71
 
-LIBS = $(SDL_LIBS) $(LIBGL_LIBS) -lbz2
72
 
+LIBS = $(SDL_LIBS) $(LIBGL_LIBS) $(XDGBASEDIR_LIBS) -lbz2
73
 
 STATIC_LIBS =
74
 
+CFLAGS+= $(XDGBASEDIR_FLAGS)
75
 
 
76
 
 # add extra objects and libraries for selected options
77
 
 ifeq ($(DBG), 1)
78
 
diff --git a/blight_input/Input_1.1.h b/blight_input/Input_1.1.h
79
 
index c2ae4a6..1a22c4b 100644
80
 
--- a/blight_input/Input_1.1.h
81
 
+++ b/blight_input/Input_1.1.h
82
 
@@ -251,6 +251,28 @@ EXPORT void CALL WM_KeyUp( WPARAM wParam, LPARAM lParam );
83
 
 *******************************************************************/
84
 
 EXPORT void CALL SetConfigDir( char *configDir );
85
 
 
86
 
+/******************************************************************
87
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
88
 
+         ORIGINAL SPEC
89
 
+  Function: SetDataDir
90
 
+  Purpose:  To pass the location where data files should be read/
91
 
+            written to.
92
 
+  input:    path to data directory
93
 
+  output:   none
94
 
+*******************************************************************/
95
 
+EXPORT void CALL SetDataDir( char *dataDir );
96
 
+
97
 
+/******************************************************************
98
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
99
 
+         ORIGINAL SPEC
100
 
+  Function: SetCacheDir
101
 
+  Purpose:  To pass the location where cache files should be read/
102
 
+            written to.
103
 
+  input:    path to cache directory
104
 
+  output:   none
105
 
+*******************************************************************/
106
 
+EXPORT void CALL SetCacheDir( char *cacheDir );
107
 
+
108
 
 #if defined(__cplusplus)
109
 
 }
110
 
 #endif
111
 
diff --git a/doc/Audio_1.1.h b/doc/Audio_1.1.h
112
 
index ea46b2d..7a6f68b 100644
113
 
--- a/doc/Audio_1.1.h
114
 
+++ b/doc/Audio_1.1.h
115
 
@@ -224,6 +224,28 @@ EXPORT void CALL RomClosed (void);
116
 
 *******************************************************************/
117
 
 EXPORT void CALL SetConfigDir( char *configDir );
118
 
 
119
 
+/******************************************************************
120
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
121
 
+         ORIGINAL SPEC
122
 
+  Function: SetDataDir
123
 
+  Purpose:  To pass the location where data files should be read/
124
 
+            written to.
125
 
+  input:    path to data directory
126
 
+  output:   none
127
 
+*******************************************************************/
128
 
+EXPORT void CALL SetDataDir( char *dataDir );
129
 
+
130
 
+/******************************************************************
131
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
132
 
+         ORIGINAL SPEC
133
 
+  Function: SetCacheDir
134
 
+  Purpose:  To pass the location where cache files should be read/
135
 
+            written to.
136
 
+  input:    path to cache directory
137
 
+  output:   none
138
 
+*******************************************************************/
139
 
+EXPORT void CALL SetCacheDir( char *cacheDir );
140
 
+
141
 
 #if defined(__cplusplus)
142
 
 }
143
 
 #endif
144
 
diff --git a/doc/Audio_1.2.h b/doc/Audio_1.2.h
145
 
index 0decf07..43045c2 100644
146
 
--- a/doc/Audio_1.2.h
147
 
+++ b/doc/Audio_1.2.h
148
 
@@ -239,6 +239,28 @@ EXPORT void CALL SetConfigDir( char *configDir );
149
 
 /******************************************************************
150
 
    NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
151
 
          ORIGINAL SPEC
152
 
+  Function: SetDataDir
153
 
+  Purpose:  To pass the location where data files should be read/
154
 
+            written to.
155
 
+  input:    path to data directory
156
 
+  output:   none
157
 
+*******************************************************************/
158
 
+EXPORT void CALL SetDataDir( char *dataDir );
159
 
+
160
 
+/******************************************************************
161
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
162
 
+         ORIGINAL SPEC
163
 
+  Function: SetCacheDir
164
 
+  Purpose:  To pass the location where cache files should be read/
165
 
+            written to.
166
 
+  input:    path to cache directory
167
 
+  output:   none
168
 
+*******************************************************************/
169
 
+EXPORT void CALL SetCacheDir( char *cacheDir );
170
 
+
171
 
+/******************************************************************
172
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
173
 
+         ORIGINAL SPEC
174
 
   Function: VolumeUp
175
 
   Purpose:  To increase the audio volume
176
 
   input:    none
177
 
diff --git a/doc/Graphics_1.3.h b/doc/Graphics_1.3.h
178
 
index 0f7843d..ed933b3 100644
179
 
--- a/doc/Graphics_1.3.h
180
 
+++ b/doc/Graphics_1.3.h
181
 
@@ -306,6 +306,28 @@ EXPORT void CALL SetConfigDir( char *configDir );
182
 
 /******************************************************************
183
 
    NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
184
 
          ORIGINAL SPEC
185
 
+  Function: SetDataDir
186
 
+  Purpose:  To pass the location where data files should be read/
187
 
+            written to.
188
 
+  input:    path to data directory
189
 
+  output:   none
190
 
+*******************************************************************/
191
 
+EXPORT void CALL SetDataDir( char *dataDir );
192
 
+
193
 
+/******************************************************************
194
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
195
 
+         ORIGINAL SPEC
196
 
+  Function: SetCacheDir
197
 
+  Purpose:  To pass the location where cache files should be read/
198
 
+            written to.
199
 
+  input:    path to cache directory
200
 
+  output:   none
201
 
+*******************************************************************/
202
 
+EXPORT void CALL SetCacheDir( char *cacheDir );
203
 
+
204
 
+/******************************************************************
205
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
206
 
+         ORIGINAL SPEC
207
 
   Function: SetRenderingCallback
208
 
   Purpose:  Allows emulator to register a callback function that will
209
 
             be called by the graphics plugin just before the the
210
 
diff --git a/doc/Input_1.1.h b/doc/Input_1.1.h
211
 
index c2ae4a6..1a22c4b 100644
212
 
--- a/doc/Input_1.1.h
213
 
+++ b/doc/Input_1.1.h
214
 
@@ -251,6 +251,28 @@ EXPORT void CALL WM_KeyUp( WPARAM wParam, LPARAM lParam );
215
 
 *******************************************************************/
216
 
 EXPORT void CALL SetConfigDir( char *configDir );
217
 
 
218
 
+/******************************************************************
219
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
220
 
+         ORIGINAL SPEC
221
 
+  Function: SetDataDir
222
 
+  Purpose:  To pass the location where data files should be read/
223
 
+            written to.
224
 
+  input:    path to data directory
225
 
+  output:   none
226
 
+*******************************************************************/
227
 
+EXPORT void CALL SetDataDir( char *dataDir );
228
 
+
229
 
+/******************************************************************
230
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
231
 
+         ORIGINAL SPEC
232
 
+  Function: SetCacheDir
233
 
+  Purpose:  To pass the location where cache files should be read/
234
 
+            written to.
235
 
+  input:    path to cache directory
236
 
+  output:   none
237
 
+*******************************************************************/
238
 
+EXPORT void CALL SetCacheDir( char *cacheDir );
239
 
+
240
 
 #if defined(__cplusplus)
241
 
 }
242
 
 #endif
243
 
diff --git a/dummy_audio/Audio_1.1.h b/dummy_audio/Audio_1.1.h
244
 
index ea46b2d..7a6f68b 100644
245
 
--- a/dummy_audio/Audio_1.1.h
246
 
+++ b/dummy_audio/Audio_1.1.h
247
 
@@ -224,6 +224,28 @@ EXPORT void CALL RomClosed (void);
248
 
 *******************************************************************/
249
 
 EXPORT void CALL SetConfigDir( char *configDir );
250
 
 
251
 
+/******************************************************************
252
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
253
 
+         ORIGINAL SPEC
254
 
+  Function: SetDataDir
255
 
+  Purpose:  To pass the location where data files should be read/
256
 
+            written to.
257
 
+  input:    path to data directory
258
 
+  output:   none
259
 
+*******************************************************************/
260
 
+EXPORT void CALL SetDataDir( char *dataDir );
261
 
+
262
 
+/******************************************************************
263
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
264
 
+         ORIGINAL SPEC
265
 
+  Function: SetCacheDir
266
 
+  Purpose:  To pass the location where cache files should be read/
267
 
+            written to.
268
 
+  input:    path to cache directory
269
 
+  output:   none
270
 
+*******************************************************************/
271
 
+EXPORT void CALL SetCacheDir( char *cacheDir );
272
 
+
273
 
 #if defined(__cplusplus)
274
 
 }
275
 
 #endif
276
 
diff --git a/dummy_input/Input_1.1.h b/dummy_input/Input_1.1.h
277
 
index c2ae4a6..1a22c4b 100644
278
 
--- a/dummy_input/Input_1.1.h
279
 
+++ b/dummy_input/Input_1.1.h
280
 
@@ -251,6 +251,28 @@ EXPORT void CALL WM_KeyUp( WPARAM wParam, LPARAM lParam );
281
 
 *******************************************************************/
282
 
 EXPORT void CALL SetConfigDir( char *configDir );
283
 
 
284
 
+/******************************************************************
285
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
286
 
+         ORIGINAL SPEC
287
 
+  Function: SetDataDir
288
 
+  Purpose:  To pass the location where data files should be read/
289
 
+            written to.
290
 
+  input:    path to data directory
291
 
+  output:   none
292
 
+*******************************************************************/
293
 
+EXPORT void CALL SetDataDir( char *dataDir );
294
 
+
295
 
+/******************************************************************
296
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
297
 
+         ORIGINAL SPEC
298
 
+  Function: SetCacheDir
299
 
+  Purpose:  To pass the location where cache files should be read/
300
 
+            written to.
301
 
+  input:    path to cache directory
302
 
+  output:   none
303
 
+*******************************************************************/
304
 
+EXPORT void CALL SetCacheDir( char *cacheDir );
305
 
+
306
 
 #if defined(__cplusplus)
307
 
 }
308
 
 #endif
309
 
diff --git a/dummy_video/Graphics_1.3.h b/dummy_video/Graphics_1.3.h
310
 
index 0f7843d..ed933b3 100644
311
 
--- a/dummy_video/Graphics_1.3.h
312
 
+++ b/dummy_video/Graphics_1.3.h
313
 
@@ -306,6 +306,28 @@ EXPORT void CALL SetConfigDir( char *configDir );
314
 
 /******************************************************************
315
 
    NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
316
 
          ORIGINAL SPEC
317
 
+  Function: SetDataDir
318
 
+  Purpose:  To pass the location where data files should be read/
319
 
+            written to.
320
 
+  input:    path to data directory
321
 
+  output:   none
322
 
+*******************************************************************/
323
 
+EXPORT void CALL SetDataDir( char *dataDir );
324
 
+
325
 
+/******************************************************************
326
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
327
 
+         ORIGINAL SPEC
328
 
+  Function: SetCacheDir
329
 
+  Purpose:  To pass the location where cache files should be read/
330
 
+            written to.
331
 
+  input:    path to cache directory
332
 
+  output:   none
333
 
+*******************************************************************/
334
 
+EXPORT void CALL SetCacheDir( char *cacheDir );
335
 
+
336
 
+/******************************************************************
337
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
338
 
+         ORIGINAL SPEC
339
 
   Function: SetRenderingCallback
340
 
   Purpose:  Allows emulator to register a callback function that will
341
 
             be called by the graphics plugin just before the the
342
 
diff --git a/glide64/Gfx1.3.h b/glide64/Gfx1.3.h
343
 
index b34c1b4..91bd0e6 100644
344
 
--- a/glide64/Gfx1.3.h
345
 
+++ b/glide64/Gfx1.3.h
346
 
@@ -754,6 +754,28 @@ EXPORT void CALL SetConfigDir( char *configDir );
347
 
 /******************************************************************
348
 
    NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
349
 
          ORIGINAL SPEC
350
 
+  Function: SetDataDir
351
 
+  Purpose:  To pass the location where data files should be read/
352
 
+            written to.
353
 
+  input:    path to data directory
354
 
+  output:   none
355
 
+*******************************************************************/
356
 
+EXPORT void CALL SetDataDir( char *dataDir );
357
 
+
358
 
+/******************************************************************
359
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
360
 
+         ORIGINAL SPEC
361
 
+  Function: SetCacheDir
362
 
+  Purpose:  To pass the location where cache files should be read/
363
 
+            written to.
364
 
+  input:    path to cache directory
365
 
+  output:   none
366
 
+*******************************************************************/
367
 
+EXPORT void CALL SetCacheDir( char *cacheDir );
368
 
+
369
 
+/******************************************************************
370
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
371
 
+         ORIGINAL SPEC
372
 
   Function: SetRenderingCallback
373
 
   Purpose:  Allows emulator to register a callback function that will
374
 
             be called by the graphics plugin just before the the
375
 
diff --git a/jttl_audio/Audio_1.2.h b/jttl_audio/Audio_1.2.h
376
 
index 0decf07..43045c2 100644
377
 
--- a/jttl_audio/Audio_1.2.h
378
 
+++ b/jttl_audio/Audio_1.2.h
379
 
@@ -239,6 +239,28 @@ EXPORT void CALL SetConfigDir( char *configDir );
380
 
 /******************************************************************
381
 
    NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
382
 
          ORIGINAL SPEC
383
 
+  Function: SetDataDir
384
 
+  Purpose:  To pass the location where data files should be read/
385
 
+            written to.
386
 
+  input:    path to data directory
387
 
+  output:   none
388
 
+*******************************************************************/
389
 
+EXPORT void CALL SetDataDir( char *dataDir );
390
 
+
391
 
+/******************************************************************
392
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
393
 
+         ORIGINAL SPEC
394
 
+  Function: SetCacheDir
395
 
+  Purpose:  To pass the location where cache files should be read/
396
 
+            written to.
397
 
+  input:    path to cache directory
398
 
+  output:   none
399
 
+*******************************************************************/
400
 
+EXPORT void CALL SetCacheDir( char *cacheDir );
401
 
+
402
 
+/******************************************************************
403
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
404
 
+         ORIGINAL SPEC
405
 
   Function: VolumeUp
406
 
   Purpose:  To increase the audio volume
407
 
   input:    none
408
 
diff --git a/main/main.c b/main/main.c
409
 
index d57bafd..3c88498 100644
410
 
--- a/main/main.c
411
 
+++ b/main/main.c
412
 
@@ -34,6 +34,8 @@
413
 
 #ifndef __WIN32__
414
 
 # include <ucontext.h> // extra signal types (for portability)
415
 
 # include <libgen.h> // basename, dirname
416
 
+# include <basedir.h> // xdg(Init|Wipe)Handle, xdg(Config|Data|Cache)Home
417
 
+# include <basedir_fs.h> // xdgMakePath
418
 
 #endif
419
 
 
420
 
 #include <sys/time.h>
421
 
@@ -152,6 +154,8 @@ static int  l_GuiEnabled = 1;           // GUI enabled?
422
 
 #endif
423
 
 
424
 
 static char l_ConfigDir[PATH_MAX] = {'\0'};
425
 
+static char l_DataDir[PATH_MAX] = {'\0'};
426
 
+static char l_CacheDir[PATH_MAX] = {'\0'};
427
 
 static char l_InstallDir[PATH_MAX] = {'\0'};
428
 
 
429
 
 static int   l_EmuMode = 0;              // emumode specified at commandline?
430
 
@@ -173,6 +177,16 @@ char *get_configpath()
431
 
     return l_ConfigDir;
432
 
 }
433
 
 
434
 
+char *get_datapath()
435
 
+{
436
 
+    return l_DataDir;
437
 
+}
438
 
+
439
 
+char *get_cachepath()
440
 
+{
441
 
+    return l_CacheDir;
442
 
+}
443
 
+
444
 
 char *get_installpath()
445
 
 {
446
 
     return l_InstallDir;
447
 
@@ -181,7 +195,7 @@ char *get_installpath()
448
 
 char *get_savespath()
449
 
 {
450
 
     static char path[PATH_MAX];
451
 
-    strncpy(path, get_configpath(), PATH_MAX-5);
452
 
+    strncpy(path, get_datapath(), PATH_MAX-5);
453
 
     strcat(path, "save/");
454
 
     return path;
455
 
 }
456
 
@@ -1075,6 +1089,8 @@ void parseCommandLine(int argc, char **argv)
457
 
         OPT_EMUMODE,
458
 
         OPT_SSHOTDIR,
459
 
         OPT_CONFIGDIR,
460
 
+        OPT_DATADIR,
461
 
+        OPT_CACHEDIR,
462
 
         OPT_INSTALLDIR,
463
 
 #ifdef DBG
464
 
     OPT_DEBUGGER,
465
 
@@ -1096,6 +1112,8 @@ void parseCommandLine(int argc, char **argv)
466
 
         {"emumode", required_argument, NULL, OPT_EMUMODE},
467
 
         {"sshotdir", required_argument, NULL, OPT_SSHOTDIR},
468
 
         {"configdir", required_argument, NULL, OPT_CONFIGDIR},
469
 
+        {"datadir", required_argument, NULL, OPT_DATADIR},
470
 
+        {"cachedir", required_argument, NULL, OPT_CACHEDIR},
471
 
         {"installdir", required_argument, NULL, OPT_INSTALLDIR},
472
 
 #ifdef DBG
473
 
         {"debugger", no_argument, NULL, OPT_DEBUGGER},
474
 
@@ -1180,6 +1198,18 @@ void parseCommandLine(int argc, char **argv)
475
 
                 else
476
 
                     printf("***Warning: Config directory '%s' is not accessible or not a directory.\n", optarg);
477
 
                 break;
478
 
+            case OPT_DATADIR:
479
 
+                if(isdir(optarg))
480
 
+                    strncpy(l_CacheDir, optarg, PATH_MAX);
481
 
+                else
482
 
+                    printf("***Warning: Cache directory '%s' is not accessible or not a directory.\n", optarg);
483
 
+                break;
484
 
+            case OPT_CACHEDIR:
485
 
+                if(isdir(optarg))
486
 
+                    strncpy(l_CacheDir, optarg, PATH_MAX);
487
 
+                else
488
 
+                    printf("***Warning: Cache directory '%s' is not accessible or not a directory.\n", optarg);
489
 
+                break;
490
 
             case OPT_INSTALLDIR:
491
 
                 if(isdir(optarg))
492
 
                     strncpy(l_InstallDir, optarg, PATH_MAX);
493
 
@@ -1249,49 +1279,79 @@ void parseCommandLine(int argc, char **argv)
494
 
 
495
 
 /** setPaths
496
 
  *  setup paths to config/install/screenshot directories. The config dir is the dir where all
497
 
- *  user config information is stored, e.g. mupen64plus.conf, save files, and plugin conf files.
498
 
+ *  user config information is stored, e.g. mupen64plus.conf, and plugin conf files.
499
 
  *  The install dir is where mupen64plus looks for common files, e.g. plugins, icons, language
500
 
  *  translation files.
501
 
+ *  The cache dir is where mupen64plus looks for rombrowser and similar caches.
502
 
+ *  The data dir is where mupen64plus looks for savegames, hires-textures and saves screenshots.
503
 
  */
504
 
 static void setPaths(void)
505
 
 {
506
 
 #ifdef __WIN32__
507
 
     strncpy(l_ConfigDir, "./", PATH_MAX);
508
 
+    strncpy(l_DataDir, "./", PATH_MAX);
509
 
+    strncpy(l_CacheDir, "./", PATH_MAX);
510
 
     strncpy(l_InstallDir, "./", PATH_MAX);
511
 
     return;
512
 
 #else
513
 
     char buf[PATH_MAX], buf2[PATH_MAX];
514
 
+    xdgHandle xdgbasedirs;
515
 
+
516
 
+    xdgInitHandle(&xdgbasedirs);
517
 
 
518
 
-    // if the config dir was not specified at the commandline, look for ~/.mupen64plus dir
519
 
+    // if the config dir was not specified at the commandline, look for ~/.config/mupen64plus dir
520
 
     if (strlen(l_ConfigDir) == 0)
521
 
     {
522
 
-        strncpy(l_ConfigDir, getenv("HOME"), PATH_MAX);
523
 
-        strncat(l_ConfigDir, "/.mupen64plus", PATH_MAX - strlen(l_ConfigDir));
524
 
+        strncpy(l_ConfigDir, xdgConfigHome(&xdgbasedirs), PATH_MAX);
525
 
+        strncat(l_ConfigDir, "/mupen64plus", PATH_MAX - strlen(l_ConfigDir));
526
 
 
527
 
-        // if ~/.mupen64plus dir is not found, create it
528
 
+        // if ~/.config/mupen64plus is not found, create it
529
 
         if(!isdir(l_ConfigDir))
530
 
         {
531
 
-            printf("Creating %s to store user data\n", l_ConfigDir);
532
 
-            if(mkdir(l_ConfigDir, (mode_t)0755) != 0)
533
 
+            printf("Creating %s to store user config\n", l_ConfigDir);
534
 
+            if(xdgMakePath(l_ConfigDir, (mode_t)0755) != 0)
535
 
             {
536
 
                 printf("Error: Could not create %s: ", l_ConfigDir);
537
 
                 perror(NULL);
538
 
                 exit(errno);
539
 
             }
540
 
+        }
541
 
+    }
542
 
+
543
 
+    // make sure config dir has a '/' on the end.
544
 
+    if(l_ConfigDir[strlen(l_ConfigDir)-1] != '/')
545
 
+        strncat(l_ConfigDir, "/", PATH_MAX - strlen(l_ConfigDir));
546
 
+
547
 
+    // if the data dir was not specified at the commandline, look for ~/.local/share/mupen64plus dir
548
 
+    if (strlen(l_DataDir) == 0)
549
 
+    {
550
 
+        strncpy(l_DataDir, xdgDataHome(&xdgbasedirs), PATH_MAX);
551
 
+        strncat(l_DataDir, "/mupen64plus", PATH_MAX - strlen(l_DataDir));
552
 
+
553
 
+        // if ~/.local/share/mupen64plus dir is not found, create it
554
 
+        if(!isdir(l_DataDir))
555
 
+        {
556
 
+            printf("Creating %s to store user data\n", l_DataDir);
557
 
+            if(xdgMakePath(l_DataDir, (mode_t)0755) != 0)
558
 
+            {
559
 
+                printf("Error: Could not create %s: ", l_DataDir);
560
 
+                perror(NULL);
561
 
+                exit(errno);
562
 
+            }
563
 
 
564
 
             // create save subdir
565
 
-            strncpy(buf, l_ConfigDir, PATH_MAX);
566
 
+            strncpy(buf, l_DataDir, PATH_MAX);
567
 
             strncat(buf, "/save", PATH_MAX - strlen(buf));
568
 
-            if(mkdir(buf, (mode_t)0755) != 0)
569
 
+            if(xdgMakePath(buf, (mode_t)0755) != 0)
570
 
             {
571
 
                 // report error, but don't exit
572
 
                 printf("Warning: Could not create %s: %s", buf, strerror(errno));
573
 
             }
574
 
 
575
 
             // create screenshots subdir
576
 
-            strncpy(buf, l_ConfigDir, PATH_MAX);
577
 
+            strncpy(buf, l_DataDir, PATH_MAX);
578
 
             strncat(buf, "/screenshots", PATH_MAX - strlen(buf));
579
 
-            if(mkdir(buf, (mode_t)0755) != 0)
580
 
+            if(xdgMakePath(buf, (mode_t)0755) != 0)
581
 
             {
582
 
                 // report error, but don't exit
583
 
                 printf("Warning: Could not create %s: %s", buf, strerror(errno));
584
 
@@ -1299,9 +1359,34 @@ static void setPaths(void)
585
 
         }
586
 
     }
587
 
 
588
 
-    // make sure config dir has a '/' on the end.
589
 
-    if(l_ConfigDir[strlen(l_ConfigDir)-1] != '/')
590
 
-        strncat(l_ConfigDir, "/", PATH_MAX - strlen(l_ConfigDir));
591
 
+    // make sure data dir has a '/' on the end.
592
 
+    if(l_DataDir[strlen(l_DataDir)-1] != '/')
593
 
+        strncat(l_DataDir, "/", PATH_MAX - strlen(l_DataDir));
594
 
+
595
 
+    // if the cache dir was not specified at the commandline, look for ~/.cache/mupen64plus dir
596
 
+    if (strlen(l_CacheDir) == 0)
597
 
+    {
598
 
+        strncpy(l_CacheDir, xdgCacheHome(&xdgbasedirs), PATH_MAX);
599
 
+        strncat(l_CacheDir, "/mupen64plus", PATH_MAX - strlen(l_CacheDir));
600
 
+
601
 
+        // if ~/.cache/mupen64plus dir is not found, create it
602
 
+        if(!isdir(l_CacheDir))
603
 
+        {
604
 
+            printf("Creating %s to store user cache\n", l_CacheDir);
605
 
+            if(xdgMakePath(l_CacheDir, (mode_t)0755) != 0)
606
 
+            {
607
 
+                printf("Error: Could not create %s: ", l_CacheDir);
608
 
+                perror(NULL);
609
 
+                exit(errno);
610
 
+            }
611
 
+        }
612
 
+    }
613
 
+
614
 
+    // make sure cache dir has a '/' on the end.
615
 
+    if(l_CacheDir[strlen(l_CacheDir)-1] != '/')
616
 
+        strncat(l_CacheDir, "/", PATH_MAX - strlen(l_CacheDir));
617
 
+
618
 
+    xdgWipeHandle(&xdgbasedirs);
619
 
 
620
 
     // if install dir was not specified at the commandline, look for it in the executable's directory
621
 
     if (strlen(l_InstallDir) == 0)
622
 
@@ -1400,7 +1485,7 @@ static void setPaths(void)
623
 
     if (!ValidScreenshotDir())
624
 
     {
625
 
         char chDefaultDir[PATH_MAX + 1];
626
 
-        snprintf(chDefaultDir, PATH_MAX, "%sscreenshots/", l_ConfigDir);
627
 
+        snprintf(chDefaultDir, PATH_MAX, "%sscreenshots/", l_DataDir);
628
 
         SetScreenshotDir(chDefaultDir);
629
 
     }
630
 
 #endif /* __WIN32__ */
631
 
@@ -1481,7 +1566,7 @@ int main(int argc, char *argv[])
632
 
     }
633
 
     // scan the plugin directory and set the config dir for the plugins
634
 
     plugin_scan_directory(dirpath);
635
 
-    plugin_set_dirs(l_ConfigDir, l_InstallDir);
636
 
+    plugin_set_dirs(l_ConfigDir, l_DataDir, l_CacheDir, l_InstallDir);
637
 
 
638
 
 #ifndef NO_GUI
639
 
     if(l_GuiEnabled)
640
 
@@ -1500,8 +1585,8 @@ int main(int argc, char *argv[])
641
 
         config_put_number("CurrentSaveSlot",0);
642
 
     }
643
 
 
644
 
-    main_message(1, 0, 0, 0, tr("Config Dir:  %s\nInstall Dir: %s\nPlugin Dir:  %s\n"), l_ConfigDir, l_InstallDir, dirpath);
645
 
-    main_message(0, 1, 0, 0, tr("Config Dir: \"%s\", Install Dir: \"%s\", Plugin Dir:  \"%s\""), l_ConfigDir, l_InstallDir, dirpath);
646
 
+    main_message(1, 0, 0, 0, tr("Config Dir:  %s\nData Dir:  %s\nCache Dir:  %s\nInstall Dir: %s\nPlugin Dir:  %s\n"), l_ConfigDir, l_DataDir, l_CacheDir, l_InstallDir, dirpath);
647
 
+    main_message(0, 1, 0, 0, tr("Config Dir: \"%s\", Data Dir: \"%s\", Cache Dir: \"%s\", Install Dir: \"%s\", Plugin Dir:  \"%s\""), l_ConfigDir, l_DataDir, l_CacheDir, l_InstallDir, dirpath);
648
 
 
649
 
     //The database needs to be opened regardless of GUI mode.
650
 
     romdatabase_open();
651
 
diff --git a/main/main.h b/main/main.h
652
 
index e597ad2..7cec0e0 100644
653
 
--- a/main/main.h
654
 
+++ b/main/main.h
655
 
@@ -40,6 +40,8 @@ extern char* g_InputPlugin;
656
 
 extern char* g_RspPlugin;
657
 
 
658
 
 char* get_configpath(void);
659
 
+char* get_datapath(void);
660
 
+char* get_cachepath(void);
661
 
 char* get_installpath(void);
662
 
 char* get_savespath(void);
663
 
 char* get_iconspath(void);
664
 
diff --git a/main/plugin.c b/main/plugin.c
665
 
index 92752be..b377ff0 100644
666
 
--- a/main/plugin.c
667
 
+++ b/main/plugin.c
668
 
@@ -66,6 +66,8 @@ static void dummy_readController(int Control, BYTE *Command) {}
669
 
 static void dummy_keyDown(WPARAM wParam, LPARAM lParam) {}
670
 
 static void dummy_keyUp(WPARAM wParam, LPARAM lParam) {}
671
 
 static void dummy_setConfigDir(char *configDir) {}
672
 
+static void dummy_setDataDir(char *dataDir) {}
673
 
+static void dummy_setCacheDir(char *cacheDir) {}
674
 
 static void dummy_setInstallDir(char *installDir) {}
675
 
 static unsigned int dummy;
676
 
 static DWORD dummy_doRspCycles(DWORD Cycles) { return Cycles; };
677
 
@@ -115,6 +117,8 @@ void (*romOpen_input)() = dummy_void;
678
 
 void (*keyDown)(WPARAM wParam, LPARAM lParam) = dummy_keyDown;
679
 
 void (*keyUp)(WPARAM wParam, LPARAM lParam) = dummy_keyUp;
680
 
 void (*setConfigDir)(char *configDir) = dummy_setConfigDir;
681
 
+void (*setDataDir)(char *dataDir) = dummy_setDataDir;
682
 
+void (*setCacheDir)(char *cacheDir) = dummy_setCacheDir;
683
 
 void (*setInstallDir)(char *installDir) = dummy_setInstallDir;
684
 
 
685
 
 void (*closeDLL_RSP)() = dummy_void;
686
 
@@ -271,7 +275,7 @@ void plugin_scan_directory(const char *plugindir)
687
 
 /* plugin_set_configdir
688
 
  *  Sets config dir of all plugins that support the SetConfigDir API call to the given dir.
689
 
  */
690
 
-void plugin_set_dirs(char* configdir, char* installdir)
691
 
+void plugin_set_dirs(char* configdir, char* datadir, char* cachedir, char* installdir)
692
 
 {
693
 
     plugin* p = NULL;
694
 
     list_node_t* node;
695
 
@@ -286,6 +290,12 @@ void plugin_set_dirs(char* configdir, char* installdir)
696
 
             setConfigDir = dlsym(p->handle, "SetConfigDir");
697
 
             if(setConfigDir)
698
 
                 setConfigDir(configdir);
699
 
+            setDataDir = dlsym(p->handle, "SetDataDir");
700
 
+            if(setDataDir)
701
 
+                setDataDir(datadir);
702
 
+            setCacheDir = dlsym(p->handle, "SetCacheDir");
703
 
+            if(setCacheDir)
704
 
+                setCacheDir(cachedir);
705
 
             setInstallDir = dlsym(p->handle, "SetInstallDir");
706
 
             if(setInstallDir)
707
 
                 setInstallDir(installdir);
708
 
diff --git a/main/plugin.h b/main/plugin.h
709
 
index 35f4f43..4b6264a 100644
710
 
--- a/main/plugin.h
711
 
+++ b/main/plugin.h
712
 
@@ -38,7 +38,7 @@ extern list_t g_PluginList;
713
 
 
714
 
 int   plugin_scan_file(const char *filepath, WORD PluginType);
715
 
 void  plugin_scan_directory(const char *plugindir);
716
 
-void  plugin_set_dirs(char* configdir, char* installdir);
717
 
+void  plugin_set_dirs(char* configdir, char* datadir, char* cachedir, char* installdir);
718
 
 void  plugin_load_plugins(const char *gfx_name, 
719
 
               const char *audio_name, 
720
 
               const char *input_name,
721
 
diff --git a/main/romcache.c b/main/romcache.c
722
 
index 5f31cc8..5ec3f40 100644
723
 
--- a/main/romcache.c
724
 
+++ b/main/romcache.c
725
 
@@ -258,7 +258,7 @@ int rom_cache_system(void* _arg)
726
 
                 if(buffer==NULL)
727
 
                     {
728
 
                     buffer = (char*)malloc(PATH_MAX*sizeof(char));
729
 
-                    snprintf(buffer, PATH_MAX, "%s%s", get_configpath(), "rombrowser.cache");
730
 
+                    snprintf(buffer, PATH_MAX, "%s%s", get_cachepath(), "rombrowser.cache");
731
 
                     config_put_string("RomCacheFile", buffer);
732
 
                     }
733
 
 
734
 
diff --git a/pre.mk b/pre.mk
735
 
index d2eb261..5c7b73c 100644
736
 
--- a/pre.mk
737
 
+++ b/pre.mk
738
 
@@ -101,6 +101,15 @@ GTK_FLAGS  = $(shell pkg-config gtk+-2.0 --cflags)
739
 
 GTK_LIBS       = $(shell pkg-config gtk+-2.0 --libs)
740
 
 GTHREAD_LIBS   = $(shell pkg-config gthread-2.0 --libs)
741
 
 
742
 
+# test for presence of libxdg-basedir
743
 
+ifeq ("$(shell pkg-config libxdg-basedir --modversion )", "")
744
 
+  $(error No libxdg-basedir development libraries found!)
745
 
+endif
746
 
+
747
 
+# set libxdg-basedir flags and libraries
748
 
+XDGBASEDIR_FLAGS       = $(shell pkg-config libxdg-basedir --cflags)
749
 
+XDGBASEDIR_LIBS        = $(shell pkg-config libxdg-basedir --libs)
750
 
+
751
 
 # set Qt flags and libraries
752
 
 # some distros append -qt4 to the binaries so look for those first
753
 
 ifeq ($(GUI), QT4)
754
 
diff --git a/rice_video/Graphics_1.3.h b/rice_video/Graphics_1.3.h
755
 
index 0f7843d..ed933b3 100644
756
 
--- a/rice_video/Graphics_1.3.h
757
 
+++ b/rice_video/Graphics_1.3.h
758
 
@@ -306,6 +306,28 @@ EXPORT void CALL SetConfigDir( char *configDir );
759
 
 /******************************************************************
760
 
    NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
761
 
          ORIGINAL SPEC
762
 
+  Function: SetDataDir
763
 
+  Purpose:  To pass the location where data files should be read/
764
 
+            written to.
765
 
+  input:    path to data directory
766
 
+  output:   none
767
 
+*******************************************************************/
768
 
+EXPORT void CALL SetDataDir( char *dataDir );
769
 
+
770
 
+/******************************************************************
771
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
772
 
+         ORIGINAL SPEC
773
 
+  Function: SetCacheDir
774
 
+  Purpose:  To pass the location where cache files should be read/
775
 
+            written to.
776
 
+  input:    path to cache directory
777
 
+  output:   none
778
 
+*******************************************************************/
779
 
+EXPORT void CALL SetCacheDir( char *cacheDir );
780
 
+
781
 
+/******************************************************************
782
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
783
 
+         ORIGINAL SPEC
784
 
   Function: SetRenderingCallback
785
 
   Purpose:  Allows emulator to register a callback function that will
786
 
             be called by the graphics plugin just before the the
787
 
diff --git a/rice_video/TextureFilters.cpp b/rice_video/TextureFilters.cpp
788
 
index e59f797..f8341fe 100644
789
 
--- a/rice_video/TextureFilters.cpp
790
 
+++ b/rice_video/TextureFilters.cpp
791
 
@@ -901,7 +901,7 @@ typedef struct {
792
 
 CSortedList<uint64,ExtTxtrInfo> gTxtrDumpInfos;
793
 
 CSortedList<uint64,ExtTxtrInfo> gHiresTxtrInfos;
794
 
 
795
 
-extern void GetPluginDir( char * Directory );
796
 
+extern void GetDataDir( char * Directory );
797
 
 extern char * right(char * src, int nchars);
798
 
 
799
 
 BOOL PathIsDirectory(char* name)
800
 
@@ -1238,7 +1238,7 @@ const char *subfolders[] = {
801
 
 void FindAllDumpedTextures(void)
802
 
 {
803
 
     char    foldername[PATH_MAX];
804
 
-    GetPluginDir(foldername);
805
 
+    GetDataDir(foldername);
806
 
     if(foldername[strlen(foldername) - 1] != '/') strcat(foldername, "/");
807
 
     strcat(foldername,"texture_dump/");
808
 
 
809
 
@@ -1279,7 +1279,7 @@ void FindAllDumpedTextures(void)
810
 
 void FindAllHiResTextures(void)
811
 
 {
812
 
     char    foldername[PATH_MAX];
813
 
-    GetPluginDir(foldername);
814
 
+    GetDataDir(foldername);
815
 
     if(foldername[strlen(foldername) - 1] != '/') strcat(foldername, "/");
816
 
     strcat(foldername,"hires_texture/");
817
 
     CheckAndCreateFolder(foldername);
818
 
@@ -1448,7 +1448,7 @@ void DumpCachedTexture( TxtrCacheEntry &entry )
819
 
         char filename2[PATH_MAX];
820
 
         char filename3[PATH_MAX];
821
 
         char gamefolder[PATH_MAX];
822
 
-        GetPluginDir(gamefolder);
823
 
+        GetDataDir(gamefolder);
824
 
         
825
 
         strcat(gamefolder,"texture_dump/");
826
 
         strcat(gamefolder,(const char*)g_curRomInfo.szGameName);
827
 
diff --git a/rice_video/Video.cpp b/rice_video/Video.cpp
828
 
index 3f3cc05..75e3ad8 100644
829
 
--- a/rice_video/Video.cpp
830
 
+++ b/rice_video/Video.cpp
831
 
@@ -41,6 +41,8 @@ unsigned char *g_pRDRAMu8 = NULL;
832
 
 
833
 
 static char g_ConfigDir[PATH_MAX] = {0};
834
 
 
835
 
+static char g_DataDir[PATH_MAX] = {0};
836
 
+
837
 
 CCritSect g_CritialSection;
838
 
 
839
 
 ///#define USING_THREAD
840
 
@@ -68,7 +70,7 @@ std::vector<uint32> frameWriteRecord;
841
 
 
842
 
 //---------------------------------------------------------------------------------------
843
 
 
844
 
-void GetPluginDir( char * Directory ) 
845
 
+void GetPluginDir( char * Directory )
846
 
 {
847
 
    if(strlen(g_ConfigDir) > 0)
848
 
    {
849
 
@@ -86,7 +88,7 @@ void GetPluginDir( char * Directory )
850
 
         {
851
 
            char path2[PATH_MAX];
852
 
            int i;
853
 
-           
854
 
+
855
 
            path[n] = '\0';
856
 
            strcpy(path2, path);
857
 
            for (i=strlen(path2)-1; i>0; i--)
858
 
@@ -99,7 +101,63 @@ void GetPluginDir( char * Directory )
859
 
                 DIR *dir;
860
 
                 struct dirent *entry;
861
 
                 int gooddir = 0;
862
 
-                
863
 
+
864
 
+                path2[i+1] = '\0';
865
 
+                dir = opendir(path2);
866
 
+                while((entry = readdir(dir)) != NULL)
867
 
+                  {
868
 
+              if(!strcmp(entry->d_name, "plugins"))
869
 
+                gooddir = 1;
870
 
+                  }
871
 
+                closedir(dir);
872
 
+                if(!gooddir) strcpy(path, "./");
873
 
+             }
874
 
+        }
875
 
+      int i;
876
 
+      for(i=strlen(path)-1; i>0; i--)
877
 
+        {
878
 
+           if(path[i] == '/') break;
879
 
+        }
880
 
+      path[i+1] = '\0';
881
 
+      strcat(path, "plugins/");
882
 
+      strcpy(Directory, path);
883
 
+   }
884
 
+}
885
 
+
886
 
+//---------------------------------------------------------------------------------------
887
 
+
888
 
+void GetDataDir( char * Directory )
889
 
+{
890
 
+   if(strlen(g_DataDir) > 0)
891
 
+   {
892
 
+      strncpy(Directory, g_DataDir, PATH_MAX);
893
 
+      // make sure there's a trailing '/'
894
 
+      if(Directory[strlen(Directory)-1] != '/')
895
 
+          strncat(Directory, "/", PATH_MAX - strlen(Directory));
896
 
+   }
897
 
+   else
898
 
+   {
899
 
+      char path[PATH_MAX];
900
 
+      int n = readlink("/proc/self/exe", path, PATH_MAX);
901
 
+      if(n == -1) strcpy(path, "./");
902
 
+      else
903
 
+        {
904
 
+           char path2[PATH_MAX];
905
 
+           int i;
906
 
+
907
 
+           path[n] = '\0';
908
 
+           strcpy(path2, path);
909
 
+           for (i=strlen(path2)-1; i>0; i--)
910
 
+             {
911
 
+                if(path2[i] == '/') break;
912
 
+             }
913
 
+           if(i == 0) strcpy(path, "./");
914
 
+           else
915
 
+             {
916
 
+                DIR *dir;
917
 
+                struct dirent *entry;
918
 
+                int gooddir = 0;
919
 
+
920
 
                 path2[i+1] = '\0';
921
 
                 dir = opendir(path2);
922
 
                 while((entry = readdir(dir)) != NULL)
923
 
@@ -1084,7 +1142,7 @@ EXPORT void CALL ReadScreen(void **dest, int *width, int *height)
924
 
          GL_RGB, GL_UNSIGNED_BYTE, *dest );
925
 
    glReadBuffer( oldMode );
926
 
 }
927
 
-    
928
 
+
929
 
 /******************************************************************
930
 
    NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
931
 
          ORIGINAL SPEC
932
 
@@ -1102,6 +1160,20 @@ EXPORT void CALL SetConfigDir(char *configDir)
933
 
 /******************************************************************
934
 
    NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
935
 
          ORIGINAL SPEC
936
 
+  Function: SetDataDir
937
 
+  Purpose:  To pass the location where data files should be read/
938
 
+            written to.
939
 
+  input:    path to data directory
940
 
+  output:   none
941
 
+*******************************************************************/
942
 
+EXPORT void CALL SetDataDir(char *dataDir)
943
 
+{
944
 
+    strncpy(g_DataDir, dataDir, PATH_MAX);
945
 
+}
946
 
+
947
 
+/******************************************************************
948
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
949
 
+         ORIGINAL SPEC
950
 
   Function: SetRenderingCallback
951
 
   Purpose:  Allows emulator to register a callback function that will
952
 
             be called by the graphics plugin just before the the
953
 
diff --git a/rsp_hle/Audio_1.1.h b/rsp_hle/Audio_1.1.h
954
 
index ea46b2d..7a6f68b 100644
955
 
--- a/rsp_hle/Audio_1.1.h
956
 
+++ b/rsp_hle/Audio_1.1.h
957
 
@@ -224,6 +224,28 @@ EXPORT void CALL RomClosed (void);
958
 
 *******************************************************************/
959
 
 EXPORT void CALL SetConfigDir( char *configDir );
960
 
 
961
 
+/******************************************************************
962
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
963
 
+         ORIGINAL SPEC
964
 
+  Function: SetDataDir
965
 
+  Purpose:  To pass the location where data files should be read/
966
 
+            written to.
967
 
+  input:    path to data directory
968
 
+  output:   none
969
 
+*******************************************************************/
970
 
+EXPORT void CALL SetDataDir( char *dataDir );
971
 
+
972
 
+/******************************************************************
973
 
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
974
 
+         ORIGINAL SPEC
975
 
+  Function: SetCacheDir
976
 
+  Purpose:  To pass the location where cache files should be read/
977
 
+            written to.
978
 
+  input:    path to cache directory
979
 
+  output:   none
980
 
+*******************************************************************/
981
 
+EXPORT void CALL SetCacheDir( char *cacheDir );
982
 
+
983
 
 #if defined(__cplusplus)
984
 
 }
985
 
 #endif
986
 
1.6.3.3
987