🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #11493

Search directories for a file mask problem...

#11493
From: Martin C
Date: Thu, 05 Feb 2004 19:53
49 lines
2276 bytes
Hi all,

I am trying to make a function that will search directory and all its
subdirectories for a file mask and delete them, although I have a problem
that the search does not cover all the directory subdirectories...so can
someone help me please by telling me what exactly I am missing here...thanks
in advance.

Code used :
=====================
bool __fastcall TForm1::SearchForFile(AnsiString Folder, const AnsiString
&MaskToFind)
{
    TSearchRec sr;
    bool returnedval = false;

    if(!Folder.IsEmpty() && (Folder[Folder.Length()] != '\\'))
        Folder += "\\";

    if(FindFirst(Folder + MaskToFind, faAnyFile, sr) == 0)
    {
        do
        {
            if((sr.Name != ".")  && (sr.Name != ".."))
            {
                if(sr.Attr & faDirectory)
                { return SearchForFile(Folder + sr.Name,  MaskToFind);
                }
                else
                {
                    if(sr.Name.AnsiCompareIC(MaskToFind) == 0)
                    {  returnedval = true;
                        break;
                    }
                    else
                    {
                    }
                }
            }
        }
        while(FindNext(sr) == 0);
        FindClose(sr);
    }
    return returnedval;
}
//--------------------------------------------------------------------------
-- 

BR
Technical Details
Message-ID: <402301fc@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,b023f6f11f20de80,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-02-05 18:57:46 PST
From: "Martin C" <martinc@aol.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Search directories for a file mask problem...
Date: Thu, 5 Feb 2004 21:53:19 +0200
Lines: 51
Organization: V Safe
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 81.10.4.238
Message-ID: <402301fc@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1076036092 81.10.4.238 (5 Feb 2004 18:54:52 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail