Hello.

I'm having a hard time figuring this out.
I want to open a file, but I don't know the filename. I know the directory the file resides in, and I know the extension ('.lay'), and I know there is only one file with that extension in the directory.

How can I do this and still have portable code?
I was thinking I could get the directory listing and test each file and see if it ends with ".lay".

Any other ideas out there?

Thanks
-V-

ms-windows call GetFirstFile() and GetNextFile(), or in *nix call opendir() and readdir(). If you used c++ you can use boost library that is portable between these two operating systems (I don't know a thing about MAC).

Damn. I was afraid there wasn't a standard cross-platform way to do this. Oh well, I just have to write a wrapper, then.

Thanks for the fast reply :)

-V-

Yes, wrapper is the way to go then just use precompiler directives to conditionally compile depending on the os.

I'd go with boost as mentioned before. It will probably be more reliable than writing your own wrapper.