* implement Find{First,Next,Close} according to Dos unit code

This commit is contained in:
mazen 2004-09-30 10:42:05 +00:00
parent 90ef672c12
commit 209e2b49ed

View File

@ -247,48 +247,120 @@ begin
end; end;
*) *)
Function DoFind(Var Rslt : TSearchRec) : Longint; Function DoFind(Var Rslt : TSearchRec) : Longint;
(* var
Var err: OSErr;
GlobSearchRec : PGlobSearchRec; s: Str255;
*)
begin begin
(* TODO fix with Rslt, paramBlock do
Result:=-1; begin
GlobSearchRec:=PGlobSearchRec(Rslt.FindHandle); ioVRefNum := searchFSSpec.vRefNum;
If (GlobSearchRec^.GlobHandle<>Nil) then if firstTime then
While (GlobSearchRec^.GlobHandle<>Nil) and not (Result=0) do ioFDirIndex := 0;
If GlobToTSearchRec(Rslt) Then Result:=0;
*) while true do
begin
s := '';
ioDirID := searchFSSpec.parID;
ioFDirIndex := ioFDirIndex + 1;
ioNamePtr := @s;
err := PBGetCatInfoSync(@paramBlock);
if err <> noErr then
begin
if err = fnfErr then
DosError := 18
else
DosError := MacOSErr2RTEerr(err);
break;
end;
attr := GetFileAttrFromPB(Rslt.paramBlock);
if ((Attr and not(searchAttr)) = 0) then
begin
name := s;
UpperString(s, true);
if FNMatch(Rslt.searchFSSpec.name, s) then
begin
size := GetFileSizeFromPB(paramBlock);
time := MacTimeToDosPackedTime(ioFlMdDat);
Result := 0;
break;
end;
end;
end;
end;
end; end;
Function FindFirst (Const Path : String; Attr : Longint; Var Rslt : TSearchRec) : Longint; Function FindFirst (Const Path : String; Attr : Longint; Var Rslt : TSearchRec) : Longint;
var
(* s: Str255;
Var
GlobSearchRec : PGlobSearchRec;
*)
begin begin
(* TODO fix fillchar(Rslt, sizeof(Rslt), 0);
New(GlobSearchRec);
GlobSearchRec^.Path:=ExpandFileName(ExtractFilePath(Path)); if path = '' then
GlobSearchRec^.GlobHandle:=Glob(Path); begin
Rslt.ExcludeAttr:=Not Attr; //!! Not correct !! Result := 3;
Rslt.FindHandle:=Longint(GlobSearchRec); Exit;
Result:=DoFind (Rslt); end;
*)
{We always also search for readonly and archive, regardless of Attr.}
Rslt.searchAttr := (Attr or (archive or readonly));
Result := PathArgToFSSpec(path, Rslt.searchFSSpec);
with Rslt do
if (Result = 0) or (Result = 2) then
begin
SearchSpec := path;
NamePos := Length(path) - Length(searchFSSpec.name);
if (Pos('?', searchFSSpec.name) = 0) and (Pos('*', searchFSSpec.name) = 0) then {No wildcards}
begin {If exact match, we don't have to scan the directory}
exactMatch := true;
Result := DoFindOne(searchFSSpec, paramBlock);
if Result = 0 then
begin
Attr := GetFileAttrFromPB(paramBlock);
if ((Attr and not(searchAttr)) = 0) then
begin
name := searchFSSpec.name;
size := GetFileSizeFromPB(paramBlock);
time := MacTimeToDosPackedTime(paramBlock.ioFlMdDat);
end
else
Result := 18;
end
else if Result = 2 then
Result := 18;
end
else
begin
exactMatch := false;
s := searchFSSpec.name;
UpperString(s, true);
Rslt.searchFSSpec.name := s;
DoFind(Rslt, true);
end;
end;
end; end;
Function FindNext (Var Rslt : TSearchRec) : Longint; Function FindNext (Var Rslt : TSearchRec) : Longint;
begin begin
Result:=DoFind (Rslt); if F.exactMatch then
Result := 18
else
Result:=DoFind (Rslt);
end; end;
@ -582,7 +654,10 @@ end.
{ {
$Log$ $Log$
Revision 1.1 2004-09-28 15:39:29 olle Revision 1.2 2004-09-30 10:42:05 mazen
* implement Find{First,Next,Close} according to Dos unit code
Revision 1.1 2004/09/28 15:39:29 olle
+ added skeleton version + added skeleton version
} }