File: write_to_userdir.patch

package info (click to toggle)
serious-engine 0~git20250224%2Bdfsg-1
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 21,816 kB
  • sloc: cpp: 142,653; yacc: 2,399; lex: 641; asm: 282; python: 121; sh: 51; makefile: 20
file content (45 lines) | stat: -rw-r--r-- 1,575 bytes parent folder | download | duplicates (2)
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
Description: write files to _fnmUserDir, ie SDL_GetPrefPath("Serious Engine");
Forwarded: not-needed
Author: Sébastien Noel <sebastien@twolife.be>
--- a/Sources/Engine/Base/Stream.cpp
+++ b/Sources/Engine/Base/Stream.cpp
@@ -1441,6 +1441,22 @@
   INDEX iFileInZip = UNZIPGetFileIndex(fnmFile);
   //const BOOL userdir_not_basedir = (_fnmUserDir != _fnmApplicationPath);
 
+  // first, try in the UserDir path
+  if (_fnmUserDir!="") {
+    // if a mod is active, try in the mod's dir
+    if (_fnmMod!="") {
+      fnmExpanded = _fnmUserDir+_fnmMod+fnmFile;
+      if (IsFileReadable_internal(fnmExpanded)) {
+        return EFP_FILE;
+      }
+    }
+
+    fnmExpanded = _fnmUserDir+fnmFile;
+    if (IsFileReadable_internal(fnmExpanded)) {
+      return EFP_FILE;
+    }
+  }
+
   // if a mod is active
   if (_fnmMod!="") {
 
@@ -1574,14 +1590,14 @@
     // if should write to mod dir
     if (_fnmMod!="" && (!FileMatchesList(_afnmBaseWriteInc, fnmFileAbsolute) || FileMatchesList(_afnmBaseWriteExc, fnmFileAbsolute))) {
       // do that
-      fnmExpanded = _fnmApplicationPath+_fnmMod+fnmFileAbsolute;
+      fnmExpanded = _fnmUserDir+_fnmMod+fnmFileAbsolute;
       fnmExpanded.SetAbsolutePath();
       VerifyDirsExist(fnmExpanded.FileDir());
       return EFP_FILE;
     // if should not write to mod dir
     } else {
       // write to base dir
-      fnmExpanded = _fnmApplicationPath+fnmFileAbsolute;
+      fnmExpanded = _fnmUserDir+fnmFileAbsolute;
       fnmExpanded.SetAbsolutePath();
       VerifyDirsExist(fnmExpanded.FileDir());
       return EFP_FILE;