mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-30 11:26:53 -05:00
33 lines
791 B
Haxe
33 lines
791 B
Haxe
package funkin.util.assets;
|
|
|
|
using StringTools;
|
|
|
|
class DataAssets
|
|
{
|
|
static function buildDataPath(path:String):String
|
|
{
|
|
return 'default:assets/data/${path}';
|
|
}
|
|
|
|
public static function listDataFilesInPath(path:String, ?suffix:String = '.json'):Array<String>
|
|
{
|
|
var textAssets = openfl.utils.Assets.list();
|
|
var queryPath = buildDataPath(path);
|
|
|
|
var results:Array<String> = [];
|
|
for (textPath in textAssets)
|
|
{
|
|
if (textPath.startsWith(queryPath) && textPath.endsWith(suffix))
|
|
{
|
|
var pathNoSuffix = textPath.substring(0, textPath.length - suffix.length);
|
|
var pathNoPrefix = pathNoSuffix.substring(queryPath.length);
|
|
|
|
// No duplicates! Why does this happen?
|
|
if (!results.contains(pathNoPrefix))
|
|
results.push(pathNoPrefix);
|
|
}
|
|
}
|
|
|
|
return results;
|
|
}
|
|
}
|