At 21:30 21-6-2007, you wrote:
Am Donnerstag, den 21.06.2007, 20:49 +0200 schrieb Marco van de Voort:
> On Thu, Jun 21, 2007 at 09:48:56PM +0400, Alex Smirnov wrote:
> > Peter Vreman ?????:
> > >If need performance and only need to have the filename you can use
> > >fpgetdents or the deprecated
> > >fpreaddir. If you need all file information like size and modified
> > >timestamp then better use the
> > >portable findfirst/findnext.
> > >
> > *Thank you, Peter!
> >
> > * Can you. please, help me to understand Dir structure, i.e
>
> The FreeBSD source has some comments
>
>   dir     = packed record
> dd_fd : cint; // file descriptor associated with directory
>         dd_loc    : clong;        // offset in current buffer
>         dd_size   : clong;        // amount of data returned by
>         getdirentries
>         dd_buf    : pchar;        // data buffer
>         dd_len    : cint;         // size of data buffer
> {$ifdef netbsdpowerpc}
>         dd_pad1   : cint;
> dd_seek : cint64; // magic cookie returned by getdirentries
> {$else}
>         dd_seek   : clong;        // magic cookie returned by getdirentries
> {$endif}
>         dd_rewind : clong;        // magic cookie for rewinding
>         dd_flags  : cint;         // flags for readdir
>    end;
>    TDir    = dir;
>    pDir    = ^dir;
>
> However I would vote against using it. Sure it saves a stat here and there,
> but it is way less portable (even amongst *nixes in time) than findfirst.

While we're at it: what does the following comment want to say? I've
been fiddling with that stuff, but that was quite a while ago and I've
forgotten the details.

from <fpc-2.0.4>/src/rtl/unix/sysutils.pp:

Function FindFirst (Const Path : String; Attr : Longint; out Rslt : TSearchRec) : Longint;

Var
  GlobSearchRec : PGlobSearchRec;

begin
  New(GlobSearchRec);
  GlobSearchRec^.Path:=ExpandFileName(ExtractFilePath(Path));
  GlobSearchRec^.GlobHandle:=Glob(Path);
Rslt.ExcludeAttr:=Not Attr and (faHidden or faSysFile or faVolumeID or faDirectory); //!! Not correct !!
  Rslt.FindHandle:=GlobSearchRec;
  Result:=DoFind (Rslt);
end;

If it's wrong, why is it in the code?
And, more important, what would be correct?

The code in the 2.1.4 is already completly rewritten. It is not in the same style as the findfirst in the Dos unit for unix that is also in 2.0.4. Please look at that code and forget the code above.

Peter

Peter

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to