🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Read all dirs (with wildcards)

#5756
From: Jason
Date: Tue, 12 Jul 2005 00:58
74 lines
3285 bytes
Thats fine :) Thanks

"Ed Mulroy" <dont_email_me@bitbuc.ket> wrote in message 
news:42d282ec@newsgroups.borland.com...
>> dir *soft
>
> So that would include all directories whose name includes "soft" which 
> have either a string terminator, a '\0' or a period, a '.', following the 
> 't'.
>
> You can search by using the Windows API functions FindFirstFile, 
> FindNextFile and FindClose.  It is convenient to put the list of names 
> found into a vector of strings.
>
> This is written to look in the root of C: and should be close.  Untested.
>
> --------------------
> #include <windows.h>
> #include <vector>
>
> typedef std::vector<std::string> string_vector;
>
> bool FindSofts(string_vector & results)
>    {
>    WIN32_FIND_DATA wfd;
>    char *fname = wfd.cFileName;
>    char  low_name[MAX_PATH];
>    HANDLE find_hand = FindFirstFile("c:\\*.*", &wfd);
>
>    results.clear(); // empty the directories list
>
>    if (find_hand != INVALID_HANDLE_VALUE)
>        {
>        do // loop to find directories
>          {
>          if (!(attribs & FILE_ATTRIBUTE_DIRECTORY)
>              {
>              continue; // if not a directory, skip to find next one
>              }
>
>          strcpy(low_name, fname); // make copy of name
>          strlwr(low_name); // force copy to lower case
>
>          char *found = strstr(low_name, "soft"); // find "soft" in name
>
>          // if something was found
>          // and the word "soft" is the end of the name
>          // or "soft" followed by a period
>          if (found && (!found[5] || !strcmp(found, "soft.")))
>              {
>              results.push_back(fname); // add the name to the list
>              }
>          } while (FindNextFile(find_hand, &wfd));
>
>        FindClose(find_hand); // close file search handle
>        }
>
>    return results.size() > 0; // return true/false on if any were found
>    }
> --------------------
>
> .  Ed
>
>> Jason wrote in message
>> news:42d27bfe$1@newsgroups.borland.com...
>>
>> I want to see all directories in that contains the word "soft" on the end 
>> something like
>>
>> dir *soft
>>
>> how can I get this with code?
>
> 
Technical Details
Message-ID: <42d28940$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsgate.cistron.nl!newsfeed.bit.nl!border1.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <42d27bfe$1@newsgroups.borland.com> <42d282ec@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,fcae796750f56a3e
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Jason" <jason851@hotmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <42d27bfe$1@newsgroups.borland.com> <42d282ec@newsgroups.borland.com>
Subject: Re: Read all dirs (with wildcards)
Date: Tue, 12 Jul 2005 03:58:53 +0300
Lines: 76
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 194.30.251.141
Message-ID: <42d28940$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1121093952 194.30.251.141 (11 Jul 2005 07:59:12 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsgate.cistron.nl!newsfeed.bit.nl!border1.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail