[fpc-pascal] Findfirst/findnext with a samba share
Sven Barth
pascaldragon at googlemail.com
Fri Mar 1 18:02:01 CET 2013
On 01.03.2013 16:08, Ludo Brands wrote:
> On 03/01/2013 12:52 PM, Sven Barth wrote:
>
>> Currently FPC allocates only one pdirent in fpopendir
>> (rtl/linux/ossysc.inc). Maybe it should first stat the directory and
>> then decide based on st_blksize how much pdirent entries to allocate
>> (but it should also provide a sane default, as there is the possiblity
>> that st_blksize is 0 for a directory).
>>
>
> The dirent struct on linux contains a char d_name[256]; as the last
> element. The kernel returns only a null terminated string instead of the
> full 256 chars. Reason why you can get many files returned in one 280
> byte block. Allocating n pdirent entries for n files would be an overkill.
> The glibc getdents.c source uses some heuristics to determine how many
> entries will fit in a buffer. They use an average of 14 chars for the
> filename.
While the kernel might pass less than 256 characters the dirent
structure contains a "dd_nextoff" field which is already used in FPC's
fpreaddir call to locate the next returned entry.
Regards,
Sven
More information about the fpc-pascal
mailing list