Glob


WarmFluffyUK

The Big Wad Bolf.
Joined
Sep 4, 2004
Messages
3,384
Location
UK
Website
www.retrotech.one
Does anyone know if there's a way to determin the difference between files and folders with the GLOB function, or is there a better way to return the contents of a folder?

I have tried this:
CODE
say(chdir("c:\"));

While( (filename = Glob("*")) != "" )
say(filename);
End;

Repeat
Frame;
Until(key(_ESC))

But that does not appear to distinguish between files and folders returned .
 
No idea. However, you can try and chdir into the returned results which seems to return 0 if a directory and and an int (possibly always positive and maybe its constant also?) when trying to chdir into a file. I have no idea if thats the right way to do it but it seems to work in the quick test i've done.
 
Use Fileinfo.

CODE
#ifdef COMPILER_VERSION
import "mod_say"
import "mod_dir"
#endif

Process Main()
Private
string filename;
Begin
While( (filename = Glob("*")) != "")
if(Fileinfo.directory)
say("[DIR] " + filename);
else
say("[FILE] " + filename);
end
End
End
 
Back
Top