1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-09-01 11:25:12 +00:00
Funkin/source/funkin/util/assets/DataAssets.hx
Hyper_ 88ed66affa chore: Add null safety to various utility and plugin classes
And add a bit of error handling to CharSelectGF & CharSelectSubState

Co-Authored-By: Linus Torvalds <torvalds@linux-foundation.org>
2025-06-23 14:13:35 -04:00

33 lines
822 B
Haxe

package funkin.util.assets;
@:nullSafety
class DataAssets
{
static function buildDataPath(path:String):String
{
return 'assets/data/${path}';
}
public static function listDataFilesInPath(path:String, suffix:String = '.json'):Array<String>
{
var textAssets = openfl.utils.Assets.list(TEXT);
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;
}
}