How to get a list of directories? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
baka_bai
Experienced Solver
Experienced Solver
Posts: 99
Joined: Fri Sep 30, 2005 10:20 pm
Contact:

How to get a list of directories?

Post by baka_bai » Mon Dec 18, 2006 4:00 pm

I been looking for a tutorial on this for a few days now with no luck. In C++ how would I be able to get a get a list of (all) directories on a certian drive?
For example, say I wanted to build a list of all directories underneath my F:\ drive in wondows or in linux all directories below /mnt/hdb1...
I just want to throw them into a vector and pump them out to flat file one path per line...
____
wxWidgest 2.8.2 / 2.8.6u
mingw32-gcc-3.4.2 / gcc 4.1.2
wxDev-CPP beta 6.10.2 / Anjuta
Dev-CPP (4.9.9.2)
XP Pro / Vista / Feodra 8

mispunt
Experienced Solver
Experienced Solver
Posts: 59
Joined: Tue Oct 19, 2004 3:23 pm
Location: Ede, Holland

Post by mispunt » Mon Dec 18, 2006 4:05 pm

Did you see the class wxDir?

When you put the content into a vector (within the while loop of the sample) you are done ;)
OS: win XP pro
Compiler: MingW
wxWidgets version: 2.6.2

baka_bai
Experienced Solver
Experienced Solver
Posts: 99
Joined: Fri Sep 30, 2005 10:20 pm
Contact:

Post by baka_bai » Mon Dec 18, 2006 4:10 pm

mispunt wrote:Did you see the class wxDir?
Yes I have, but I was looking for something using the regular CPP streams. Mainly since I haven't used them in this manner before.
____
wxWidgest 2.8.2 / 2.8.6u
mingw32-gcc-3.4.2 / gcc 4.1.2
wxDev-CPP beta 6.10.2 / Anjuta
Dev-CPP (4.9.9.2)
XP Pro / Vista / Feodra 8

djenyc
Earned a small fee
Earned a small fee
Posts: 10
Joined: Fri Aug 18, 2006 5:02 pm

Post by djenyc » Mon Dec 18, 2006 5:08 pm

C++ standard library does not support parsing directories. You need a third-party library like wxWidgets, or Boost or platform specific implementation like POSIX/ Win32 API.

baka_bai
Experienced Solver
Experienced Solver
Posts: 99
Joined: Fri Sep 30, 2005 10:20 pm
Contact:

Post by baka_bai » Tue Dec 19, 2006 1:17 am

Can I get a different example of it usage, maybe something a little more complex?
____
wxWidgest 2.8.2 / 2.8.6u
mingw32-gcc-3.4.2 / gcc 4.1.2
wxDev-CPP beta 6.10.2 / Anjuta
Dev-CPP (4.9.9.2)
XP Pro / Vista / Feodra 8

Post Reply