title: count number of subdirectories of a given path
body: <p>I need to do some searching in the filesystem and would like to present a progress indication.<br>
  A rough approximation of that is the number of directories traversed.  </p>
  
  <pre><code>function GetSubDirCount(Path : String): integer;
  var
    Index : Integer;
    Temp : String;
    SearchRec : TSearchRec;
  begin
    Result:= 0;
    Temp:= Path;
  
    if Path[Length(Path)] &lt;&gt; SysUtils.PathDelim then begin
      Path:= Path + SysUtils.PathDelim;
    end;
    Path:= Path + '*.';
  
    Index:= FindFirst(Path, faDirectory, SearchRec);
  
    while Index = 0 do begin
      if (SearchRec.Name = '.') or (SearchRec.Name = '..') then begin
        Index:= FindNext(SearchRec);
        Continue;
      end;
  
      Inc(Result);
      Result:= Result + GetSubDirCount(Temp + SysUtils.PathDelim + SearchRec.Name);
      Index:= FindNext(SearchRec);
    end;
  
    FindClose(SearchRec);
  end;
  </code></pre>
  
  <p>I currently use the above code, is there a faster way?<br>
  I'm only interested in the count.<br>
  If there's a really fast way to get the number of files as well that would be a bonus.</p>