🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Search directories for a file mask problem...

#11378
From: Martin C
Date: Fri, 06 Feb 2004 13:58
57 lines
2901 bytes
Hi Remy,

Thank you so much for your reply and code. Actually I tried the code and it
works great as long as I sending (*.*) to MaskToFind parameter, although
when I tried to change the file mask to something like (*.gif) for example
it didn't return any file found. please find below the code that I used. So
I will appreciate it if you can tell me why this problem occurs

P.S. I replaced MatchesMask function with AnsiString Pos function as I had
problems compiling the code with MatchesMask (returns error call to
undefined function).

Once again thank you so much for your help

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

        Folder = IncludeTrailingBackslash(Folder);
        if(FindFirst(Folder + "*.*", faAnyFile, sr) == 0)
        {
            do
            {
                if( (sr.Name != ".")  && (sr.Name != "..") )
                {
                    if(sr.Attr & faDirectory)
                    {  returnedval = SearchForFileByGambit(Folder + sr.Name,
MaskToFind);
                    }
                    else
                    {
                         if(sr.Name.Pos(MaskToFind)== 0)
                        {
                             ListBox1->Items->Add(sr.Name);
                             returnedval = true;
                        }
                        else
                        {   returnedval = false;
                        }
                    }
                }
            }
            while( (!returnedval) && (FindNext(sr) == 0) );
            FindClose(sr);
        }
        return returnedval;
}
//--------------------------------------------------------------------------
--

"Remy Lebeau (TeamB)" <gambit47.no.spam@no.spam.yahoo.com> wrote in message
news:40232de8$1@newsgroups.borland.com...
>
> Try this code instead:
>
Technical Details
Message-ID: <40240050@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <402301fc@newsgroups.borland.com> <40232de8$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,b023f6f11f20de80
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-02-06 13:04:43 PST
From: "Martin C" <martinc@aol.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <402301fc@newsgroups.borland.com> <40232de8$1@newsgroups.borland.com>
Subject: Re: Search directories for a file mask problem...
Date: Fri, 6 Feb 2004 15:58:27 +0200
Lines: 59
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: <40240050@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1076101200 81.10.4.238 (6 Feb 2004 13:00:00 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail