mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-26 23:20:26 +02:00
lazutils: FindClose in try finally
This commit is contained in:
parent
cd514961b0
commit
df08d02d68
@ -113,6 +113,7 @@ begin
|
|||||||
Result:=false;
|
Result:=false;
|
||||||
CurSrcDir:=CleanAndExpandDirectory(DirectoryName);
|
CurSrcDir:=CleanAndExpandDirectory(DirectoryName);
|
||||||
if FindFirstUTF8(CurSrcDir+GetAllFilesMask,DeleteMask,FileInfo)=0 then begin
|
if FindFirstUTF8(CurSrcDir+GetAllFilesMask,DeleteMask,FileInfo)=0 then begin
|
||||||
|
try
|
||||||
repeat
|
repeat
|
||||||
// check if special file
|
// check if special file
|
||||||
if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') then
|
if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') then
|
||||||
@ -125,8 +126,10 @@ begin
|
|||||||
if not DeleteFileUTF8(CurFilename) then exit;
|
if not DeleteFileUTF8(CurFilename) then exit;
|
||||||
end;
|
end;
|
||||||
until FindNextUTF8(FileInfo)<>0;
|
until FindNextUTF8(FileInfo)<>0;
|
||||||
end;
|
finally
|
||||||
FindCloseUTF8(FileInfo);
|
FindCloseUTF8(FileInfo);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
if (not OnlyChildren) and (not RemoveDirUTF8(CurSrcDir)) then exit;
|
if (not OnlyChildren) and (not RemoveDirUTF8(CurSrcDir)) then exit;
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
@ -562,6 +565,7 @@ begin
|
|||||||
Ambiguous:=false;
|
Ambiguous:=false;
|
||||||
if FindFirstUTF8(CurDir+GetAllFilesMask,faAnyFile,FileInfo)=0 then
|
if FindFirstUTF8(CurDir+GetAllFilesMask,faAnyFile,FileInfo)=0 then
|
||||||
begin
|
begin
|
||||||
|
try
|
||||||
repeat
|
repeat
|
||||||
// check if special file
|
// check if special file
|
||||||
if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='')
|
if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='')
|
||||||
@ -584,8 +588,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
until FindNextUTF8(FileInfo)<>0;
|
until FindNextUTF8(FileInfo)<>0;
|
||||||
end;
|
finally
|
||||||
FindCloseUTF8(FileInfo);
|
FindCloseUTF8(FileInfo);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
if (AliasFile<>'') and (not Ambiguous) then begin
|
if (AliasFile<>'') and (not Ambiguous) then begin
|
||||||
// better filename found -> replace
|
// better filename found -> replace
|
||||||
Result:=CurDir+AliasFile+copy(Result,EndPos,length(Result));
|
Result:=CurDir+AliasFile+copy(Result,EndPos,length(Result));
|
||||||
@ -604,6 +610,7 @@ begin
|
|||||||
Result:='';
|
Result:='';
|
||||||
CurDir:=ExtractFilePath(ResolveDots(Filename));
|
CurDir:=ExtractFilePath(ResolveDots(Filename));
|
||||||
if FindFirstUTF8(CurDir+GetAllFilesMask,faAnyFile, FileInfo)=0 then begin
|
if FindFirstUTF8(CurDir+GetAllFilesMask,faAnyFile, FileInfo)=0 then begin
|
||||||
|
try
|
||||||
ShortFilename:=ExtractFilename(Filename);
|
ShortFilename:=ExtractFilename(Filename);
|
||||||
repeat
|
repeat
|
||||||
// check if special file
|
// check if special file
|
||||||
@ -621,8 +628,10 @@ begin
|
|||||||
// fits case insensitive
|
// fits case insensitive
|
||||||
Result:=CurDir+FileInfo.Name;
|
Result:=CurDir+FileInfo.Name;
|
||||||
until FindNextUTF8(FileInfo)<>0;
|
until FindNextUTF8(FileInfo)<>0;
|
||||||
end;
|
finally
|
||||||
FindCloseUTF8(FileInfo);
|
FindCloseUTF8(FileInfo);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function FindDefaultExecutablePath(const Executable: string;
|
function FindDefaultExecutablePath(const Executable: string;
|
||||||
|
@ -611,11 +611,14 @@ begin
|
|||||||
Path:=ExtractFilePath(Filename);
|
Path:=ExtractFilePath(Filename);
|
||||||
NameOnly:=ExtractFileNameOnly(Filename);
|
NameOnly:=ExtractFileNameOnly(Filename);
|
||||||
if FindFirstUTF8(Path+GetAllFilesMask,faAnyFile,FileInfo)=0 then
|
if FindFirstUTF8(Path+GetAllFilesMask,faAnyFile,FileInfo)=0 then
|
||||||
|
try
|
||||||
repeat
|
repeat
|
||||||
if GetPOFilenameParts(FileInfo.Name, CurUnitName, CurLang) and (NameOnly=CurUnitName) then
|
if GetPOFilenameParts(FileInfo.Name, CurUnitName, CurLang) and (NameOnly=CurUnitName) then
|
||||||
Result.Add(Path+FileInfo.Name);
|
Result.Add(Path+FileInfo.Name);
|
||||||
until FindNextUTF8(FileInfo)<>0;
|
until FindNextUTF8(FileInfo)<>0;
|
||||||
|
finally
|
||||||
FindCloseUTF8(FileInfo);
|
FindCloseUTF8(FileInfo);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure UpdatePoFileTranslations(const BasePOFilename: string; BasePOFile: TPOFile);
|
procedure UpdatePoFileTranslations(const BasePOFilename: string; BasePOFile: TPOFile);
|
||||||
|
Loading…
Reference in New Issue
Block a user