mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 19:19:18 +02:00
LazUtils: Move FileSearchUtf8 to LazFileUtils (and inline it in FileUtil).
Part of the ongoing restructuring of LazFileUtils/FileUtil. git-svn-id: trunk@41568 -
This commit is contained in:
parent
05b0c79893
commit
8df292bbb6
@ -1234,36 +1234,8 @@ end;
|
|||||||
function FileSearchUTF8(const Name, DirList: String): String;
|
function FileSearchUTF8(const Name, DirList: String): String;
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function FileSearchUTF8(const Name, DirList: String; ImplicitCurrentDir : Boolean = True): String;
|
function FileSearchUTF8(const Name, DirList: String; ImplicitCurrentDir : Boolean = True): String;
|
||||||
Var
|
|
||||||
I : longint;
|
|
||||||
Temp : String;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=Name;
|
Result := LazFileUtils.FileSearchUTF8(Name, DirList, ImplicitCurrentDir);
|
||||||
temp:=SetDirSeparators(DirList);
|
|
||||||
// Start with checking the file in the current directory
|
|
||||||
If ImplicitCurrentDir and (Result <> '') and FileExistsUTF8(Result) Then
|
|
||||||
exit;
|
|
||||||
while True do begin
|
|
||||||
If Temp = '' then
|
|
||||||
Break; // No more directories to search - fail
|
|
||||||
I:=pos(PathSeparator,Temp);
|
|
||||||
If I<>0 then
|
|
||||||
begin
|
|
||||||
Result:=Copy (Temp,1,i-1);
|
|
||||||
system.Delete(Temp,1,I);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
Result:=Temp;
|
|
||||||
Temp:='';
|
|
||||||
end;
|
|
||||||
If Result<>'' then
|
|
||||||
Result:=AppendPathDelim(Result)+Name;
|
|
||||||
If (Result <> '') and FileExistsUTF8(Result) Then
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
Result:='';
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
|
@ -249,7 +249,7 @@ function FileGetAttrUTF8(const FileName: String): Longint; inline;
|
|||||||
function FileSetAttrUTF8(const Filename: String; Attr: longint): Longint; inline;
|
function FileSetAttrUTF8(const Filename: String; Attr: longint): Longint; inline;
|
||||||
function DeleteFileUTF8(const FileName: String): Boolean; inline;
|
function DeleteFileUTF8(const FileName: String): Boolean; inline;
|
||||||
function RenameFileUTF8(const OldName, NewName: String): Boolean; inline;
|
function RenameFileUTF8(const OldName, NewName: String): Boolean; inline;
|
||||||
function FileSearchUTF8(const Name, DirList : String; ImplicitCurrentDir : Boolean = True): String;
|
function FileSearchUTF8(const Name, DirList : String; ImplicitCurrentDir : Boolean = True): String; inline;
|
||||||
function FileIsReadOnlyUTF8(const FileName: String): Boolean; inline;
|
function FileIsReadOnlyUTF8(const FileName: String): Boolean; inline;
|
||||||
function GetCurrentDirUTF8: String; inline;
|
function GetCurrentDirUTF8: String; inline;
|
||||||
function SetCurrentDirUTF8(const NewDir: String): Boolean; inline;
|
function SetCurrentDirUTF8(const NewDir: String): Boolean; inline;
|
||||||
|
@ -84,7 +84,7 @@ function FileGetAttrUTF8(const FileName: String): Longint;
|
|||||||
function FileSetAttrUTF8(const Filename: String; Attr: longint): Longint;
|
function FileSetAttrUTF8(const Filename: String; Attr: longint): Longint;
|
||||||
function DeleteFileUTF8(const FileName: String): Boolean;
|
function DeleteFileUTF8(const FileName: String): Boolean;
|
||||||
function RenameFileUTF8(const OldName, NewName: String): Boolean;
|
function RenameFileUTF8(const OldName, NewName: String): Boolean;
|
||||||
function FileSearchUTF8(const Name, DirList : String): String;
|
function FileSearchUTF8(const Name, DirList : String; ImplicitCurrentDir : Boolean = True): String;
|
||||||
function FileIsReadOnlyUTF8(const FileName: String): Boolean;
|
function FileIsReadOnlyUTF8(const FileName: String): Boolean;
|
||||||
function GetCurrentDirUTF8: String;
|
function GetCurrentDirUTF8: String;
|
||||||
function SetCurrentDirUTF8(const NewDir: String): Boolean;
|
function SetCurrentDirUTF8(const NewDir: String): Boolean;
|
||||||
@ -845,9 +845,37 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function FileSearchUTF8(const Name, DirList: String): String;
|
function FileSearchUTF8(const Name, DirList: String; ImplicitCurrentDir : Boolean = True): String;
|
||||||
|
Var
|
||||||
|
I : longint;
|
||||||
|
Temp : String;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=SysToUTF8(SysUtils.FileSearch(UTF8ToSys(Name),UTF8ToSys(DirList)));
|
Result:=Name;
|
||||||
|
temp:=SetDirSeparators(DirList);
|
||||||
|
// Start with checking the file in the current directory
|
||||||
|
If ImplicitCurrentDir and (Result <> '') and FileExistsUTF8(Result) Then
|
||||||
|
exit;
|
||||||
|
while True do begin
|
||||||
|
If Temp = '' then
|
||||||
|
Break; // No more directories to search - fail
|
||||||
|
I:=pos(PathSeparator,Temp);
|
||||||
|
If I<>0 then
|
||||||
|
begin
|
||||||
|
Result:=Copy (Temp,1,i-1);
|
||||||
|
system.Delete(Temp,1,I);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
Result:=Temp;
|
||||||
|
Temp:='';
|
||||||
|
end;
|
||||||
|
If Result<>'' then
|
||||||
|
Result:=AppendPathDelim(Result)+Name;
|
||||||
|
If (Result <> '') and FileExistsUTF8(Result) Then
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
Result:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function FileIsReadOnlyUTF8(const FileName: String): Boolean;
|
function FileIsReadOnlyUTF8(const FileName: String): Boolean;
|
||||||
|
Loading…
Reference in New Issue
Block a user