Not sure if there is another way to check if a file exists but you can do:
if ( exists( "myfile") )
{
//file exists
}
function exists( filename )
{
try
{
f = file( "myfile", "r" )
return true;
}
catch ( e )
{
print( "couldn't open file: " + filename + "\n" );
}
return false;
}
For a directory listing, include the file module and use DirectoryListing:
fe.load_module("file");
local dir = DirectoryListing( path );
foreach ( f in dir.results )
{
print( "file: " + f + "\n" );
}