Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » How to read a dirctory?

This thread is locked; no one can reply to it. rss feed Print
How to read a dirctory?
Moving Shadow
Member #5,973
July 2005
avatar

Is it possible to find out what files exist in a directory in C/C++?

Evert
Member #794
November 2000
avatar

Of course!

Moving Shadow
Member #5,973
July 2005
avatar

Mind giving me an example!?

miran
Member #2,407
June 2002

Read the Allegro manual! The part about files. :)

--
sig used to be here

LennyLen
Member #5,313
December 2004
avatar

findfirst/findnext

For example if you want to print the nhame of every file in a directory:

struct ffblk f;
int done = findfirst("*.*", &f, FA_HIDDEN | FA_SYSTEM);
while (!done)
{
  printf("%s\n", f.ff_name);
  done = findnext(&f);
}

[edit]

Quote:

Read the Allegro manual! The part about files.

al_findfirst
al_findnext
al_findclose

He did say C/C++, not C/C++ and Allegro. ;)

Moving Shadow
Member #5,973
July 2005
avatar

Excellent, excellent.....now.....how would I copy and paste a file, given the file name?

A J
Member #3,025
December 2002
avatar

copy filename destination

___________________________
The more you talk, the more AJ is right. - ML

Thomas Fjellstrom
Member #476
June 2000
avatar

When not using allegro, I prefer:

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

CGamesPlay
Member #2,559
July 2002
avatar

And under windows, FindFirst/FindNext or something with those substrings.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Murat AYIK
Member #6,514
October 2005
avatar

I will print out this thread;D

_____________________________________________________
"The world doesn't care about what storms you sailed through, it is interested in whether you brought the ship to the dock or not!"

Go to: