You've already forked CEF4Delphi
mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-06-22 22:17:48 +02:00
Delete the cache and cookies directories in a thread
This commit is contained in:
@ -52,9 +52,9 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows, WinApi.ActiveX,{$ENDIF} System.Classes, System.SysUtils, System.UITypes, System.Math,
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows, WinApi.ActiveX,{$ENDIF} System.IOUtils, System.Classes, System.SysUtils, System.UITypes, System.Math,
|
||||
{$ELSE}
|
||||
{$IFDEF MSWINDOWS}Windows, ActiveX,{$ENDIF} Classes, SysUtils, Controls, Graphics, Math,
|
||||
{$IFDEF MSWINDOWS}Windows, ActiveX,{$ENDIF} {$IFDEF DELPHI14_UP}IOUtils,{$ENDIF} Classes, SysUtils, Controls, Graphics, Math,
|
||||
{$ENDIF}
|
||||
uCEFTypes, uCEFInterfaces, uCEFLibFunctions, uCEFResourceHandler,
|
||||
uCEFRegisterCDMCallback;
|
||||
@ -221,6 +221,8 @@ procedure LogicalToDevice(var aRect : TCEFRect; const aDeviceScaleFactor : doubl
|
||||
function GetScreenDPI : integer;
|
||||
function GetDeviceScaleFactor : single;
|
||||
|
||||
function DeleteDirContents(const aDirectory : string) : boolean;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
@ -1814,4 +1816,41 @@ begin
|
||||
Result := GetScreenDPI / 96;
|
||||
end;
|
||||
|
||||
function DeleteDirContents(const aDirectory : string) : boolean;
|
||||
var
|
||||
TempRec : TSearchRec;
|
||||
TempPath : string;
|
||||
begin
|
||||
Result := True;
|
||||
|
||||
try
|
||||
if (length(aDirectory) > 0) and
|
||||
DirectoryExists(aDirectory) and
|
||||
(FindFirst(aDirectory + '\*', faAnyFile, TempRec) = 0) then
|
||||
try
|
||||
repeat
|
||||
TempPath := aDirectory + PathDelim + TempRec.Name;
|
||||
|
||||
if ((TempRec.Attr and faDirectory) <> 0) then
|
||||
begin
|
||||
if (TempRec.Name <> '.') and (TempRec.Name <> '..') then
|
||||
begin
|
||||
if DeleteDirContents(TempPath) then
|
||||
Result := RemoveDir(TempPath) and Result
|
||||
else
|
||||
Result := False;
|
||||
end;
|
||||
end
|
||||
else
|
||||
Result := DeleteFile(TempPath) and Result;
|
||||
until (FindNext(TempRec) <> 0) or not(Result);
|
||||
finally
|
||||
FindClose(TempRec);
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('DeleteDirContents', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Reference in New Issue
Block a user