Qbasicnews.com

Full Version: C++ equivalent of DIR$
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everyone, n00b here so please be patient with me:

Im trying to write a CAD package in C++, and currently I'm attempting to make a simple file browser for it that simply reads a given directory and returns all the files in it which I can then store in an array for display.

Rather like the QuickBasic DIR (or was it DIR$ ??) command.

However, here's the snag, I cant use any OS specific API calls, as this thing needs to work in any OS.

Can it be done?

Thanks in advance.
Well, I think there is no way to make this portable without having to code for each specific system and make use of #ifdef and stuff.

In GCC compilers you can use findfirst and findnext. In MSVC you use _findfirst and _findnext but they take a different data structure.

You can also try the file object.

Anyhow, it is better to create a filesystem class yourself and write specific ports of it so you just change the file and compile for each system.
Thanks na_th_an,

I thought this may be the case, i'll probably won't bother adding a file browser thing until the end, just use a textbox for a path+filename for the time being

Thanks again.
If your using allegro, you can use it's built in routines for that, and although teh defuault gui is ugly, there are lots of guis(like 20) for allegro that give you the file select and make it look really nice.

I can point you to a few of them if you want.

Allegro works on the majority of popular pc platforms.
Thanks, but:

I just spent the last 6 months writing a GUI / window manager from scratch using nothing but primitives from OpenGL (like GL_LINES etc), and designing a kind of scripting language to control it all. Great fun was that. I was looking to extend it with a file browser, hence the question.

Heres a screenie of it so far, 80KB

http://www.squeakfix.co.uk/rage3d/256designshot.gif

I know it looks really really rough, I haven't even thought about cleaning it up yet, and I need to get round to drawing another font, once I can find my old drawing proggy (done in QBasic as it happens)

Anyway, thanks for the help, appreciated.
Looking cool!!!!
Quote:If your using allegro, you can use it's built in routines for that, and although teh defuault gui is ugly, there are lots of guis(like 20) for allegro that give you the file select and make it look really nice.

I can point you to a few of them if you want.

Allegro works on the majority of popular pc platforms.

I too recommend Allegro. It works on just about *any* platform. You might want to ask the same question in www.allegro.cc 's forum. You might get more specific answers. Though nath has answered pretty much everything =P