Asset manifest fix on Android

This commit is contained in:
Joshua Granick
2019-07-10 15:17:26 -07:00
parent 555395235f
commit 8624394ca4
2 changed files with 45 additions and 4 deletions

View File

@@ -721,7 +721,7 @@ class AssetLibrary
if (Reflect.hasField(asset, "path"))
{
paths.set(id, __cacheBreak(basePath + Reflect.field(asset, "path")));
paths.set(id, __cacheBreak(__resolvePath(basePath + Reflect.field(asset, "path"))));
}
if (Reflect.hasField(asset, "pathGroup"))
@@ -730,7 +730,7 @@ class AssetLibrary
for (i in 0...pathGroup.length)
{
pathGroup[i] = __cacheBreak(basePath + pathGroup[i]);
pathGroup[i] = __cacheBreak(__resolvePath(basePath + pathGroup[i]));
}
pathGroups.set(id, pathGroup);
@@ -772,6 +772,47 @@ class AssetLibrary
}
}
@:noCompletion private function __resolvePath(path:String):String
{
path = StringTools.replace(path, "\\", "/");
path = StringTools.replace(path, "//", "/");
if (path.indexOf("./") > -1)
{
var split = path.split("/");
var newPath = [];
for (i in 0...split.length)
{
if (split[i] == "..")
{
if (i == 0 || newPath[i - 1] == "..")
{
newPath.push("..");
}
else
{
newPath.pop();
}
}
else if (split[i] == ".")
{
if (i == 0)
{
newPath.push(".");
}
}
else
{
newPath.push(split[i]);
}
}
path = newPath.join("/");
}
return path;
}
// Event Handlers
@:noCompletion private function loadAudioBuffer_onComplete(id:String, audioBuffer:AudioBuffer):Void
{

View File

@@ -161,7 +161,7 @@ class AssetManifest
basePath = path;
}
StringTools.replace(basePath, "\\", "/");
basePath = StringTools.replace(basePath, "\\", "/");
while (StringTools.endsWith(basePath, "/"))
{
@@ -200,7 +200,7 @@ class AssetManifest
rootPath = path;
}
StringTools.replace(rootPath, "\\", "/");
rootPath = StringTools.replace(rootPath, "\\", "/");
while (StringTools.endsWith(rootPath, "/"))
{