Skip to content

Commit 20f5057

Browse files
committed
Hopefully fix the paths unix fix
1 parent f6558c4 commit 20f5057

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

source/funkin/backend/assets/Paths.hx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@ class Paths
2222
public static var assetsTree:AssetsLibraryList;
2323

2424
public static var tempFramesCache:Map<String, FlxFramesCollection> = [];
25+
#if (sys && !windows)
26+
static var tempPathsCache:Map<String, Null<String>> = [];
27+
#end
2528

2629
public static function init() {
2730
FlxG.signals.preStateSwitch.add(function() {
2831
tempFramesCache.clear();
32+
#if (sys && !windows)
33+
tempPathsCache.clear();
34+
#end
2935
});
3036
}
3137

@@ -35,29 +41,29 @@ class Paths
3541
#if (sys && !windows)
3642
if (Assets.exists(fixedPath)) return fixedPath;
3743
else if (Flags.PATHS_UNIX_FIX) {
44+
if (tempPathsCache.exists(fixedPath)) return tempPathsCache.get(fixedPath);
45+
3846
final isFile = path.lastIndexOf(".") != -1, parts = path.split("/");
39-
final n = parts.length - 1;
47+
final n = parts.length - 1, keyCache = fixedPath;
4048

4149
fixedPath = prefix;
4250
for (i => part in parts) {
43-
final partIsFile = isFile && i == n;
44-
final lower = part.toLowerCase(), entries = partIsFile ? assetsTree.getFiles(fixedPath) : assetsTree.getFolders(fixedPath);
51+
final lower = part.toLowerCase(), entries = (isFile && i == n) ? assetsTree.getFiles(fixedPath) : assetsTree.getFolders(fixedPath);
4552
var pass = false;
4653

4754
for (entry in entries) if (entry.toLowerCase() == lower) {
4855
pass = true;
49-
if (partIsFile) fixedPath += entry;
50-
else fixedPath += entry + "/";
56+
fixedPath += i == n ? entry : entry + "/";
5157
break;
5258
}
5359

5460
if (!pass) {
55-
if (nullFail) return null;
56-
else fixedPath += part;
61+
if (nullFail) return tempPathsCache[keyCache] = null;
62+
else fixedPath += i == n ? part : part + "/";
5763
}
5864
}
5965

60-
return fixedPath;
66+
return tempPathsCache[keyCache] = fixedPath;
6167
}
6268
else if (!nullFail) return fixedPath;
6369
#else

0 commit comments

Comments
 (0)