mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-12 10:29:10 +02:00
+ implemented FindFirst, FindNext and FindClose in SysUtils for the WASI platform
This commit is contained in:
parent
090cc8fa8f
commit
8e730d20db
@ -43,6 +43,10 @@ Type
|
|||||||
TFindData = TNativeNTFindData;
|
TFindData = TNativeNTFindData;
|
||||||
{$define SEARCHREC_USEFINDDATA}
|
{$define SEARCHREC_USEFINDDATA}
|
||||||
{$endif}
|
{$endif}
|
||||||
|
{$ifdef wasi}
|
||||||
|
TFindData = TWasiFindData;
|
||||||
|
{$define SEARCHREC_USEFINDDATA}
|
||||||
|
{$endif}
|
||||||
|
|
||||||
// The actual unicode search record
|
// The actual unicode search record
|
||||||
TUnicodeSearchRec = Record
|
TUnicodeSearchRec = Record
|
||||||
|
@ -26,7 +26,7 @@ interface
|
|||||||
{$modeswitch advancedrecords}
|
{$modeswitch advancedrecords}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
wasiapi;
|
wasiapi, wasiutil;
|
||||||
|
|
||||||
{$DEFINE OS_FILESETDATEBYNAME}
|
{$DEFINE OS_FILESETDATEBYNAME}
|
||||||
{$DEFINE HAS_SLEEP}
|
{$DEFINE HAS_SLEEP}
|
||||||
@ -37,6 +37,9 @@ uses
|
|||||||
{ OS has an ansistring/single byte environment variable API }
|
{ OS has an ansistring/single byte environment variable API }
|
||||||
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
{$define SYSUTILS_HAS_ANSISTR_ENVVAR_IMPL}
|
||||||
|
|
||||||
|
type
|
||||||
|
TWasiFindData = TWasiSearchRec;
|
||||||
|
|
||||||
{ Include platform independent interface part }
|
{ Include platform independent interface part }
|
||||||
{$i sysutilh.inc}
|
{$i sysutilh.inc}
|
||||||
|
|
||||||
@ -44,7 +47,7 @@ uses
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
sysconst, wasiutil;
|
sysconst;
|
||||||
|
|
||||||
{$DEFINE FPC_FEXPAND_UNC} (* UNC paths are supported *)
|
{$DEFINE FPC_FEXPAND_UNC} (* UNC paths are supported *)
|
||||||
{$DEFINE FPC_FEXPAND_DRIVES} (* Full paths begin with drive specification *)
|
{$DEFINE FPC_FEXPAND_DRIVES} (* Full paths begin with drive specification *)
|
||||||
@ -526,21 +529,49 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
Function InternalFindFirst (Const Path : RawByteString; Attr : Longint; out Rslt : TAbstractSearchRec; var Name: RawByteString) : Longint;
|
Function InternalFindFirst (Const Path : RawByteString; Attr : Longint; out Rslt : TAbstractSearchRec; var Name: RawByteString) : Longint;
|
||||||
|
var
|
||||||
|
derror: longint;
|
||||||
begin
|
begin
|
||||||
{ not yet implemented }
|
Result:=-1;
|
||||||
Result := -1;
|
{ this is safe even though Rslt actually contains a refcounted field, because
|
||||||
|
it is declared as "out" and hence has already been initialised }
|
||||||
|
fillchar(Rslt,sizeof(Rslt),0);
|
||||||
|
if Path='' then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
derror:=WasiFindFirst(Path, Attr, Rslt.FindData);
|
||||||
|
if derror=0 then
|
||||||
|
result:=0
|
||||||
|
else
|
||||||
|
result:=-1;
|
||||||
|
|
||||||
|
Name:=Rslt.FindData.Name;
|
||||||
|
Rslt.Attr:=Rslt.FindData.Attr;
|
||||||
|
Rslt.Size:=Rslt.FindData.Size;
|
||||||
|
Rslt.Time:=Rslt.FindData.Time div 1000000000;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function InternalFindNext (var Rslt : TAbstractSearchRec; var Name : RawByteString) : Longint;
|
Function InternalFindNext (var Rslt : TAbstractSearchRec; var Name : RawByteString) : Longint;
|
||||||
|
var
|
||||||
|
derror: longint;
|
||||||
begin
|
begin
|
||||||
{ not yet implemented }
|
derror:=WasiFindNext(Rslt.FindData);
|
||||||
Result := -1;
|
if derror=0 then
|
||||||
|
result:=0
|
||||||
|
else
|
||||||
|
result:=-1;
|
||||||
|
|
||||||
|
Name:=Rslt.FindData.Name;
|
||||||
|
Rslt.Attr:=Rslt.FindData.Attr;
|
||||||
|
Rslt.Size:=Rslt.FindData.Size;
|
||||||
|
Rslt.Time:=Rslt.FindData.Time div 1000000000;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Procedure InternalFindClose(var Handle: THandle);
|
Procedure InternalFindClose(var Handle: THandle; var FindData: TFindData);
|
||||||
begin
|
begin
|
||||||
|
WasiFindClose(FindData);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user