Subj : Re: Sub-tree search To : notbg From : Georges Date : Mon Jul 04 2005 05:41 pm Bob Gonder wrote: > Georges wrote: > > >> Bob Gonder wrote: > >> > Note that this is just written, and untested. > >> > There may be typeos, and the fnmerge functions might need added > >> > slashes between the old path and the new ff_name, in which case, use > >> > strcpy/strcat instead. A good defense woulde be to check the passed > >> > path for an ending '\\' at the very beginning of the function. > >> > >Bob, > > Two things - > > Three, really... > > >(1) > >It reports well on the named directory but i t doesn't scan sub-dirs in its > >present form! > > >> > fnmerge( mypath,NULL,path, "*.*" ,NULL); > > might need changing maybe "*" instead of "*.*" > > >> > done = findfirst( mypath, &fb, 0 ); > > Might also want to change the attribute from 0 to FA_DIREC > Also, look closely at mypath for any manipulation errors. > > > // then recurse through all the subfolders > > while (!done) > > { > > if( (fb.ff_attrib&FA_DIREC) ==FA_DIREC ) > > > >fb.ff_attrib is always a space (32). > > 32 (0x20) is FA_ARCH which is normal for all entries. > What you are looking for is 0x10 (in addition to any other bits) > So, you might get 48 (0x30) for a directory entry (0x30&0x10==0x10) > > >(2) We need the full address of found files to be returned. > > You have the path and the filename. Put them together. > > >ps - I've substituted 'FindClose' for 'findclose' as that was not known. > > Not a good idea. Those are from different libraries, and have no > guarantee of working together. > In fact, it wouldn't surprise me if the fact that you aren't closing > the fb properly causes the second findfirst to function improperly. > > If you use findfirst then you need to use findclose > They are the DOS functions found in dir.h > > You could also use FindFirst and FindNext and FindClose > They are the (I think) RW C++ lib as they take an AnsiString. > > Or the Win32 api: FindFirstFile/FindNextFile/FindClose > in windows.h (winbase, actually, but that is included by windows.h) Bob, Don't get me wrong - I only tried 'FindClose' because 'findclose' didn't work and I could find no reference to 'findclose' in the book! I did a very full trial with your original code but it never got into a sub-directory! Any modifications t suggest? Georges .