CONTENT OF SNIPPET
Sample listing of files and directories. The method works on Linux like Windows (in any case Vista / Seven because not tested on XP and before, but Vista / Seven are compatible POSIX not XP and before, so not on that it works).
The operation is simple, we use functions of the POSIX standard, any compatible system can use it without any problem.
C++ SOURCE / EXAMPLE:
using namespace std;
DIR* rep = opendir(".");
if ( rep != NULL )
struct dirent* ent;
while ( (ent = readdir(rep) ) != NULL )
cout << ent->d_name << endl;
The code is in C ++ (use of cost) but it is identical in C. opendir allows to open the directory, readdir to read it and close the farm. For the system, a directory is a folder just like a file, so to know if it is a folder and possibly listed so recursively, then we must call opendir on the directory which we just retrieved the name.
It is certainly possible to do otherwise but I have not looked for this side yet.