Archived

This topic is now archived and is closed to further replies.

List Files In Directory?

This topic is 6026 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I have a program Im making for school, using the "Marine biology" casestudy as a guide(reference, More like i have never looked at it and made my aquarium in 3d while everyone''s elses is a 2d matrix), and i just want mine to be 200% better then all the others in my class, How can i get(retrieve) all the file names in a folder. Like pass a function a directory(apstring) and it returns a vector(apvector) containing strings(APSTRINGS) of all the files in that directory.

Share on other sites
Use FindFirstFile, FindNextFile, and FindClose from Win32.

Alternatively, MSVCRT provides _findfirst, _findnext and _findclose.

Can I by any chance see what you've done to the case study files? I'm pretty amazed that someone decided to improve on AP classes. You're taking the AB test, right?

[edited by - IndirectX on April 17, 2002 12:01:54 AM]

Share on other sites
I mostly have rewritten the entire class structure to be easier for my extreme changes. Apvector and matrix and apstring were changed to include "windows.h" so they give errors in popups instead of couts, since im not using a console.

The Structure of it is like this(Sorta)
Notes*
The simulation class and neigbor class were combined with environment and plot. Instead of 1 fish perblock i allow for 10(Look for squares with 2 or 3 fish stacked on each other).
They can only eat, breed things in their same square.

Theyre are 3 images of what i have made so far at.

http://www.geocities.com/vbslashandburn/fish1.jpg
http://www.geocities.com/vbslashandburn/fish2.jpg
http://www.geocities.com/vbslashandburn/fish3.jpg

(Master Class) Holds all information.
(Environment Class)
Holds all fish and effects, also does all stepping. Move was removed from the fish.
Effects are like when toxic waste barrels fall down and destroy the fish. Or the cool air bubles.
(Fish Class) Holds information about fish
Food Amount
X Position
Y Position
Gender
Race (Silver or blue, etc skin)
Diet (Meat or algae)
Hungry (Am i hungry)
Pregnat(Am I)
Age (WorldTime) (How Old am I)
(Plot Class)
Number of fish im a block of land, Up to 10
(Static Object Class)
Holds information about "Reefs", "Crabs", "Starfish", "Seaweed"
X Y Z Position
(WorldTime Class)
Tells how old a object (Fish, Or world is)
Used for Night / Day Cycle

Share on other sites
Impressive. Maybe you should post a demo or something when you''re finished.

Share on other sites
I might, I think it would be over 800K with all the resource files (Textures, 3D Modles)

And how are those functions used to return file names?

Share on other sites
They stuff them into WIN32_FIND_DATA you pass to them.

Share on other sites
Is theyre an example i can use, im still new to the windows things.

Share on other sites
Untested:

  WIN32_FIND_DATA wfd;HANDLE hFind = FindFirstFile("*.dat", &wfd);if (hFind){	do {		apstring filename = wfd.cFileName;	// convert to apstring if you want, or use cFileName directly							// you can also use other members of wfd, like file size	} while (FindNextFile(hFind, &wfd));	FindClose(hFind);}

Share on other sites
Thanks, now i can make a neat user interface to select the environment to load.

Share on other sites
As a side note: since you''re redoing most of the AP stuff anyway, why not use STL? It seems much more efficient and certainly has more functionality.

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 13
• 14
• 9
• 9
• 9
• Forum Statistics

• Total Topics
632927
• Total Posts
3009241
• Who's Online (See full list)

There are no registered users currently online

×