home *** CD-ROM | disk | FTP | other *** search
- {$R-,S+,I+,D+,F-,V-,B-,N-,L+ }
- {$M $4000,0,0}
- PROGRAM KillIt;
- (********************************************************)
- (* Uses SearchEngine to find and display matching files *)
- (* in any subdirectory and total their sizes. E.g., to *)
- (* find all Pascal files, execute KILLIT *.PAS *)
- (********************************************************)
- USES DOS,CRT,Engine;
-
- VAR
- template, path : STRING;
- ErrCode : Byte;
- Total : LongInt;
-
- {$F+} Procedure KillFile(VAR S : SearchRec; path : PathStr); {$F-}
- Var
- TheFileName : String;
- FileVar : Text;
- Ch : Char;
- X,Y : Byte;
- Begin
- TheFileName := path + S.Name;
- Write(TheFileName); Write(' Kill This File (Y/N) ? ');
- X := WhereX; Y := WhereY;
- Repeat Ch := ReadKey; Ch := UpCase(Ch); Until Ch In['Y','N'];
- GotoXY(X,Y); WriteLn(Ch);
- If Ch = 'Y' Then
- Begin
- Assign(FileVar,TheFileName);
- ReWrite(FileVar);
- Close(FileVar);
- Erase(FileVar);
- Total := Total + S.Size
- End;
- End;
-
- Procedure Validate;
- {Validate the command line parameter}
- VAR P : Byte;
- Ext : ExtStr;
- Begin
- If ParamCount <> 1 Then
- Begin
- WriteLn('SYNTAX: "KILLIT [path]filespec"');
- Halt;
- End;
- FSplit(ParamStr(1), path, template, Ext);
- If Length(path) = 2 Then path := path + '\';
- template := template + Ext;
- (*If no path specIfied, search from root of
- current volume*)
- If path = '' Then
- Begin
- GetDir(0, path);
- If Length(path) = 2 Then path := path + '\' Else path[0] := #3;
- End;
- End;
-
- Procedure SetScreen;
- Begin
- TextColor(LightGray);
- TextBackGround(Black);
- ClrScr;
- End;
-
- Procedure DoTheWork;
- Begin
- WriteLn;
- WriteLn('KILLIT.EXE : File Zapping Utility.');
- WriteLn('Written by : William L. Mabee, CRNA');
- WriteLn;
- WriteLn('Searching for "', template, '" in or below "', path, '"');
- WriteLn;
- SearchEngineAll(path, template, Archive, KillFile, ErrCode);
- WriteLn;
- Writeln('File(s) occupied ',Total,' bytes of disk space.')
- End;
-
- Begin
- SetScreen;
- Total := 0;
- Validate;
- DoTheWork;
- End.