How do I check that given file does exist? Right now, I got following function:
public static function readCharacters(file:String = "")
{
var members:Array<Character> = [];
var root:Xml = Xml.parse(Assets.getText("init/" + file)).firstElement();
//trace(root);
return members;
}
As you can see, it gets the file from where ever it's called. Now, I know there is a danger here: What if the file does not exist? I tried looking over OpenFL/NME API but I can't find the answer and last time I tried it crashed my program.
So, what is the error return for getText? Is it null or an empty string? I want to know so that if the function gets an file that does not exist, it will return null, which will be interpreted as an error. Once I get that out of the way, I can focus on parsing the interiors and making sure that the file is legit.