Accessing Directorys

T

Thomas Brendgen

Hello,

in my Programm I get the path of a directory (e.g. c:\windows\temp [in
Windows] or \root [in Linux]). Now I want to now which files are in this
directory. I need the filenames of them and if it's possible the information
if there a subdirectorys and the name of them.

But I just know functions which are only available under Windows, but I need
some, wich works under Linux as well.

Can somebody help me?

Thanks in advance ;)
 
J

Jonathan Turkanis

Thomas said:
Hello,

in my Programm I get the path of a directory (e.g. c:\windows\temp [in
Windows] or \root [in Linux]). Now I want to now which files are in
this directory. I need the filenames of them and if it's possible the
information if there a subdirectorys and the name of them.

But I just know functions which are only available under Windows, but
I need some, wich works under Linux as well.

Can somebody help me?

Try Boost.Filesystem:

http://www.boost.org/libs/filesystem/doc/index.htm

it has a pretty good chance of becoming part of the standard library in a future
version of C++ (prbably with some modifications and extensions).

Jonathan
 
R

Rennie deGraaf

Thomas said:
Hello,

in my Programm I get the path of a directory (e.g. c:\windows\temp [in
Windows] or \root [in Linux]). Now I want to now which files are in this
directory. I need the filenames of them and if it's possible the information
if there a subdirectorys and the name of them.

But I just know functions which are only available under Windows, but I need
some, wich works under Linux as well.

Can somebody help me?

Thanks in advance ;)

The C++ standard doesn't (yet) define any classes or functions for
traversing directory trees. POSIX defines a C-language interface in
dirent.h, which is available on Linux and most other *nix systems; your
C++ compiler should be able to access it. I don't know if it's
supported under Win32 or not. The dirent interface works a lot like
stdio; look up opendir(), readdir(), and scandir() for details.

Rennie
 
D

DHOLLINGSWORTH2

Thomas Brendgen said:
Hello,

in my Programm I get the path of a directory (e.g. c:\windows\temp [in
Windows] or \root [in Linux]). Now I want to now which files are in this
directory. I need the filenames of them and if it's possible the
information if there a subdirectorys and the name of them.

But I just know functions which are only available under Windows, but I
need some, wich works under Linux as well.

Can somebody help me?

Thanks in advance ;)
I dont mean to get off subject, but why not write 2 programms, instead of 2
programms in one that is seperated by #ifdef 's ?

It seems like a lot of overhead just to say you've got it all in one file.
 
R

Rolf Magnus

DHOLLINGSWORTH2 said:
in my Programm I get the path of a directory (e.g. c:\windows\temp [in
Windows] or \root [in Linux]). Now I want to now which files are in this
directory. I need the filenames of them and if it's possible the
information if there a subdirectorys and the name of them.

But I just know functions which are only available under Windows, but I
need some, wich works under Linux as well.

Can somebody help me?

Thanks in advance ;)
I dont mean to get off subject, but why not write 2 programms, instead of
2 programms in one that is seperated by #ifdef 's ?

It seems like a lot of overhead just to say you've got it all in one file.

Are you sure you answered to the right posting?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top