views:

214

answers:

4

Hi!

I'm wondering how do you do stuff like gettling file information, searching through directories/subdirectories in c++? Is there a particular library that I should be looking at?

I'm seeing stuff like this in some examples:

#include <sys/types.h>
#include <sys/stat.h>

Not sure where they came from.. Thanks!

EDIT: I'm programming in Windows btw

+5  A: 

Boost filesystem comes to mind.

You can call me Chuck
Seconded. This is a terrific cross-platform library.
rlbond
+4  A: 

In windows you can use the Win32 API - FindFirstFile & FindNextFile for searching in folders, and various GetFileXXX calls.

See here for more info: MSDN information on file APIs

Jason Williams
A: 

Standard C++ has no directory access functions. On Windows, your choice is between a cross platform library such as Boost, or use of the Windows native FindFirstFile and associated functions.

anon
+1  A: 

If you are using MFC, see CFileFind. Even if you aren't, check out its implementation (if you are using Visual Studio and have installed the MFC source).

sean e