mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-29 19:20:38 +02:00
* readdir now uses getdents, patch from Joost van der Sluis
This commit is contained in:
parent
e0c4a0ed01
commit
939044763b
@ -152,6 +152,7 @@ begin
|
|||||||
ptr^.dd_fd:=fd;
|
ptr^.dd_fd:=fd;
|
||||||
ptr^.dd_loc:=0;
|
ptr^.dd_loc:=0;
|
||||||
ptr^.dd_size:=0;
|
ptr^.dd_size:=0;
|
||||||
|
ptr^.dd_nextoff:=0;
|
||||||
ptr^.dd_max:=sizeof(ptr^.dd_buf^);
|
ptr^.dd_max:=sizeof(ptr^.dd_buf^);
|
||||||
Fpopendir:=ptr;
|
Fpopendir:=ptr;
|
||||||
end;
|
end;
|
||||||
@ -164,22 +165,30 @@ begin
|
|||||||
dispose(dirp);
|
dispose(dirp);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function Fpreaddir(dirp : pdir) : pdirent; [public, alias : 'FPC_SYSC_READDIR'];
|
Function Fpreaddir(dirp : pdir) : pdirent; [public, alias: 'FPC_SYSC_READDIR'];
|
||||||
|
var bytes : longint;
|
||||||
{Different from Linux, Readdir on BSD is based on Getdents, due to the
|
dp : pdirent;
|
||||||
missing of the readdir syscall.
|
|
||||||
Getdents requires the buffer to be larger than the blocksize.
|
|
||||||
This usually the sectorsize =512 bytes, but maybe tapedrives and harddisks
|
|
||||||
with blockmode have this higher?}
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if do_SysCall(SysCall_nr_readdir,TSysParam(dirp^.dd_fd),TSysParam(dirp^.dd_buf),TSysParam(1))=0 Then
|
repeat
|
||||||
{ the readdir system call returns the number of bytes written }
|
if dirp^.dd_nextoff >= dirp^.dd_size then
|
||||||
Fpreaddir:=nil
|
begin
|
||||||
else
|
bytes := do_SysCall(SysCall_nr_getdents,TSysParam(dirp^.dd_fd),TSysParam(dirp^.dd_buf),TSysParam(dirp^.dd_max));
|
||||||
Fpreaddir:=dirp^.dd_buf
|
if bytes <= 0 then
|
||||||
|
begin
|
||||||
|
fpreaddir := nil;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
dirp^.dd_size := bytes;
|
||||||
|
dirp^.dd_nextoff := 0;
|
||||||
|
end;
|
||||||
|
dp := pdirent(ptrint(dirp^.dd_buf)+dirp^.dd_nextoff);
|
||||||
|
inc(dirp^.dd_nextoff,dp^.d_reclen);
|
||||||
|
inc(dirp^.dd_loc,dp^.d_reclen);
|
||||||
|
until dp^.d_fileno <> 0; // Don't show deleted files
|
||||||
|
Fpreaddir := dp;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{*****************************************************************************
|
{*****************************************************************************
|
||||||
--- Process:Process & program handling - related calls ---
|
--- Process:Process & program handling - related calls ---
|
||||||
*****************************************************************************}
|
*****************************************************************************}
|
||||||
@ -487,7 +496,10 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.19 2004-03-27 14:34:23 florian
|
Revision 1.20 2004-04-12 16:33:42 peter
|
||||||
|
* readdir now uses getdents, patch from Joost van der Sluis
|
||||||
|
|
||||||
|
Revision 1.19 2004/03/27 14:34:23 florian
|
||||||
* use rt_sigaction syscall on arm
|
* use rt_sigaction syscall on arm
|
||||||
|
|
||||||
Revision 1.18 2004/02/21 16:27:29 marco
|
Revision 1.18 2004/02/21 16:27:29 marco
|
||||||
|
Loading…
Reference in New Issue
Block a user