2022-03-08 03:13:53 -05:00
|
|
|
package funkin.util.assets;
|
|
|
|
|
|
|
|
class DataAssets
|
|
|
|
{
|
|
|
|
static function buildDataPath(path:String):String
|
|
|
|
{
|
2023-01-22 19:55:30 -05:00
|
|
|
return 'assets/data/${path}';
|
2022-03-08 03:13:53 -05:00
|
|
|
}
|
|
|
|
|
2022-09-13 01:09:30 -04:00
|
|
|
public static function listDataFilesInPath(path:String, ?suffix:String = '.json'):Array<String>
|
2022-03-08 03:13:53 -05:00
|
|
|
{
|
|
|
|
var textAssets = openfl.utils.Assets.list();
|
|
|
|
var queryPath = buildDataPath(path);
|
|
|
|
|
|
|
|
var results:Array<String> = [];
|
|
|
|
for (textPath in textAssets)
|
|
|
|
{
|
2022-09-13 01:09:30 -04:00
|
|
|
if (textPath.startsWith(queryPath) && textPath.endsWith(suffix))
|
2022-03-08 03:13:53 -05:00
|
|
|
{
|
2022-09-13 01:09:30 -04:00
|
|
|
var pathNoSuffix = textPath.substring(0, textPath.length - suffix.length);
|
2022-03-08 03:13:53 -05:00
|
|
|
var pathNoPrefix = pathNoSuffix.substring(queryPath.length);
|
2022-03-21 00:19:05 -04:00
|
|
|
|
|
|
|
// No duplicates! Why does this happen?
|
|
|
|
if (!results.contains(pathNoPrefix))
|
|
|
|
results.push(pathNoPrefix);
|
2022-03-08 03:13:53 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
}
|