[fpc-pascal] Is there a FindAllDirs command like FindAllFiles?

Bo Berglund bo.berglund at gmail.com
Sat Jul 25 11:30:28 CEST 2020


On Sat, 25 Jul 2020 10:51:37 +0200, Bart via fpc-pascal
<fpc-pascal at lists.freepascal.org> wrote:

>On Sat, Jul 25, 2020 at 12:24 AM Bo Berglund via fpc-pascal
><fpc-pascal at lists.freepascal.org> wrote:
>
>> But I would like to enumerate the subdirectories themselves (without
>> the content).
>
>Take a look at how FindAllFiles is implemented.
>It should be relatively easy to modify it so that it discards files
>and only adds folders to the list.
>

I already looked there but it just sends me deeper yet until I do not
follow the logic anymore...
Here is what I get when I look at the definition:

procedure FindAllFiles(AList: TStrings; const SearchPath: String;
  SearchMask: String; SearchSubDirs: Boolean; DirAttr: Word);
var
  Searcher: TListFileSearcher;
begin
  Searcher := TListFileSearcher.Create(AList);
  Searcher.DirectoryAttribute := DirAttr;
  try
    Searcher.Search(SearchPath, SearchMask, SearchSubDirs);
  finally
    Searcher.Free;
  end;
end;

The item that is not described in the documentation is the argument
"DirAttr" as I mentioned, can that be used for this problem?

I still do not understand what it does since it is not described in
the documentation either:

https://wiki.freepascal.org/FindAllFiles

Meanwhile I found a sysutils function: GetDirs()

https://www.freepascal.org/docs-html/rtl/sysutils/getdirs.html

But this uses arrays of PChar where I want to populate a TStrings
list.


-- 
Bo Berglund
Developer in Sweden



More information about the fpc-pascal mailing list