Get path and filename of all files in a given dir and its subdirs

I was given this code a while back. I finally got around to testing it (with some changes to put the files in a different place)…

void AddFiles(AnsiString path/*, TDataSet *DataSet*/)
TSearchRec sr;
int f;
    f = FindFirst(path+"\\*.*", faAnyFile, sr);
    while( !f )
        if(sr.Attr & faDirectory)
                if(sr.Name != "."   &&   sr.Name != "..")
                        path.sprintf("%s%s%s", path, "\\", sr.Name);
                        AddFiles(path/*, DataSet*/);
                Form1->ListBox1->Items->Add(path+ "\\"+ sr.Name);
                //DataSet->FieldByName("Name")->Value = sr.Name;
                /* other fields ... */
        f = FindNext(sr);

It doesn’t work properly. In the beginning it gets mixed up..

a real structure of…


gets messed up like this…


and eventually it stops including the root or sub\sub folders and ‘path’ just contains a subfolder (without its root folders)

this is completely useless for aquring useable full-path filenames.

so either can you tell me where the code is going wrong… or give me some advice on how to get the full path filenames in a dir and all its subdirs.

I want it to be as basic as possible. i.e. no uncommon advanced c++ features. stuff that a builder noob is likely to be able to debug.

Installing Python 3.0 on Cygwin

The Question

What is the correct way to install Python 3.0 alongside Python 2.x using Cygwin?


I already have a working copy of Cygwin, and Python 2.x is installed within Cygwin (/lib/python2.x, not c:\python2.x).

Also, I would like to be able to call python 3 separately (and only intentionally) by leaving python pointing to Python 2.x to preserve existing dependencies. I would like to use python30 or some alternative.

Any pointers to guides on the subject would be much appreciated. I cannot seem to find one either at the cygwin site or