unit xxxUnit1;
interface
uses ToolDef;
function xxxDeleAllFiles(Path, Mask:
string; AllVerz, DeleSubDir, ToPapierkorb: boolean; WaitProc: TProc =
nil): boolean;
overload;
implementation
uses SysUtils,
ToolFile;
function xxxDeleAllFiles(Path, Mask:
string; AllVerz, DeleSubDir, ToPapierkorb: boolean; WaitProc: TProc =
nil): boolean;
var Find : integer;
SR : TSearchRec;
fn :
string;
begin
result := False;
Path := PathToFilename(Path, '
');
Find := FindFirst(Path+Mask, faAnyFile-faDirectory, SR);
while Find = 0
do begin
if (SR.
Name <> '
.')
and (SR.
Name <> '
..')
then begin
fn := PathToFileName(Path, SR.
Name);
if (SR.Attr
and SysUtils.faReadOnly) <> 0
// geschützte Datei?
then begin
FileSetAttr(fn, SR.Attr
and not(SysUtils.faReadOnly));
// schreibschutz entfernen
DeleFileToPapierkorb(fn);
// und in Papaierkorb löschen
end
else
if ToPapierkorb
then DeleFileToPapierkorb(fn)
else DeleteFile(fn);
result := True;
if (@WaitProc <>
Nil)
then WaitProc;
end;
Find := FindNext(SR);
end;
FindClose(SR);
if AllVerz
then begin
Find := FindFirst(Path+'
*.*', faDirectory, SR);
while Find = 0
do begin
if (SR.
Name <> '
.')
and (SR.
Name <> '
..')
and (SR.Attr
and faDirectory > 0)
then begin
fn := Path+SR.
Name+'
\';
result := xxxDeleAllFiles(fn, Mask, True, DeleSubDir, ToPapierkorb)
or result;
if DeleSubDir
and result
then RemoveDir(fn);
end;
Find := FindNext(SR);
end;
FindClose(SR);
end;
end;
end.