Удалить из директории проекта лишние файлы

{codecitation class=»brush: pascal; gutter: false;» width=»600px»}

Оформил: DeeCo

Автор: http://www.swissdelphicenter.ch

program Clean;

{

The program registers as a explorer extension.

Use rightclick on a Delphiproject directory and choose Clean Delphi files.

Place the executable somewhere in program files and run once.

Dieses Program registriert sich beim Ausfuhren als

Explorer-Erweiterung.

Mit einem Rechtsklick auf ein Delphi Verzeichnis und

einem Klick auf «Clean Delphi files» werden die Verzeichnisse «aufgeraumt».

}

uses

SysUtils, Registry, WinTypes, FileCtrl;

var

dir: string;

const

// HKEY_CLASSES_ROOT

DirExtensionKey = ‘Directory\shell\clean’;

SubKey = ‘\command’;

procedure PerformAction(const dir, fname: string);

// Set selected attributes for a file.

begin

if not SysUtils.DeleteFile(dir fname) then

begin

end;

end;

procedure ScanDirectory(const dir, filemask: string);

// Call performaction for every file which looks like filemask

var

SearchRec: TSearchRec;

begin

if not DirectoryExists(dir) then

begin

MessageBox(0, ‘Directory not found’, ‘Clean’, mb_ok);

Halt;

end;

if dir » then ChDir(dir);

// Search subdirs ?

if True then

begin

if FindFirst(‘*.*’, faDirectory, SearchRec) = 0 then

repeat

if (SearchRec.Name ‘.’) and (SearchRec.Name ‘..’) and

((SearchRec.Attr and faDirectory) = faDirectory) then

ScanDirectory(SearchRec.Name, filemask);

until (FindNext(SearchRec) 0);

SysUtils.FindClose(SearchRec);

end;

// Ennumerate all files in current directory

if FindFirst(filemask, faAnyFile, SearchRec) = 0 then

repeat

if (SearchRec.Name ‘.’) and (SearchRec.Name ‘..’) and

((SearchRec.Attr and faDirectory) = 0) then

PerformAction(», SearchRec.Name);

until (FindNext(SearchRec) 0);

SysUtils.FindClose(SearchRec);

// Directory up

Chdir(‘..’);

end;

procedure DoPopupReg;

var

reg: TRegistry;

begin

try

reg := TRegistry.Create;

except

Exit;

end;

if True then

with reg do

begin

RootKey := HKEY_CLASSES_ROOT;

OpenKey(DirExtensionkey, True);

WriteString(», ‘Clean Del

Добавить комментарий