|
@@ -352,49 +352,48 @@ end;
|
|
|
|
|
|
Function FSearch(path: pathstr; dirlist: string): pathstr;
|
|
|
var
|
|
|
- i,p1 : longint;
|
|
|
+ p1 : longint;
|
|
|
s : searchrec;
|
|
|
newdir : pathstr;
|
|
|
begin
|
|
|
- write ('FSearch ("',path,'","',dirlist,'"');
|
|
|
-{ check if the file specified exists }
|
|
|
- findfirst(path,anyfile,s);
|
|
|
+ { No wildcards allowed in these things }
|
|
|
+ if (pos('?',path)<>0) or (pos('*',path)<>0) then
|
|
|
+ begin
|
|
|
+ fsearch:='';
|
|
|
+ exit;
|
|
|
+ end;
|
|
|
+ { check if the file specified exists }
|
|
|
+ findfirst(path,anyfile and not(directory),s);
|
|
|
if doserror=0 then
|
|
|
- begin
|
|
|
+ begin
|
|
|
findclose(s);
|
|
|
fsearch:=path;
|
|
|
exit;
|
|
|
- end;
|
|
|
-{ No wildcards allowed in these things }
|
|
|
- if (pos('?',path)<>0) or (pos('*',path)<>0) then
|
|
|
- fsearch:=''
|
|
|
- else
|
|
|
+ end;
|
|
|
+ { allow backslash as slash }
|
|
|
+ DoDirSeparators(dirlist);
|
|
|
+ repeat
|
|
|
+ p1:=pos(';',dirlist);
|
|
|
+ if p1<>0 then
|
|
|
+ begin
|
|
|
+ newdir:=copy(dirlist,1,p1-1);
|
|
|
+ delete(dirlist,1,p1);
|
|
|
+ end
|
|
|
+ else
|
|
|
begin
|
|
|
- { allow backslash as slash }
|
|
|
- DoDirSeparators(dirlist);
|
|
|
- repeat
|
|
|
- p1:=pos(';',dirlist);
|
|
|
- if p1<>0 then
|
|
|
- begin
|
|
|
- newdir:=copy(dirlist,1,p1-1);
|
|
|
- delete(dirlist,1,p1);
|
|
|
- end
|
|
|
- else
|
|
|
- begin
|
|
|
- newdir:=dirlist;
|
|
|
- dirlist:='';
|
|
|
- end;
|
|
|
- if (newdir<>'') and (not (newdir[length(newdir)] in ['/',':'])) then
|
|
|
- newdir:=newdir+'/';
|
|
|
- findfirst(newdir+path,anyfile,s);
|
|
|
- if doserror=0 then
|
|
|
- newdir:=newdir+path
|
|
|
- else
|
|
|
- newdir:='';
|
|
|
- until (dirlist='') or (newdir<>'');
|
|
|
- fsearch:=newdir;
|
|
|
+ newdir:=dirlist;
|
|
|
+ dirlist:='';
|
|
|
end;
|
|
|
- findclose(s);
|
|
|
+ if (newdir<>'') and (not (newdir[length(newdir)] in [DirectorySeparator,DriveSeparator])) then
|
|
|
+ newdir:=newdir+DirectorySeparator;
|
|
|
+ findfirst(newdir+path,anyfile and not(directory),s);
|
|
|
+ if doserror=0 then
|
|
|
+ newdir:=newdir+path
|
|
|
+ else
|
|
|
+ newdir:='';
|
|
|
+ findclose(s);
|
|
|
+ until (dirlist='') or (newdir<>'');
|
|
|
+ fsearch:=newdir;
|
|
|
end;
|
|
|
|
|
|
|