home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / KILLIT.ZIP / KILLIT.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1990-04-29  |  2.1 KB  |  86 lines

  1. {$R-,S+,I+,D+,F-,V-,B-,N-,L+ }
  2. {$M $4000,0,0}
  3. PROGRAM KillIt;
  4.   (********************************************************)
  5.   (* Uses SearchEngine to find and display matching files *)
  6.   (* in any subdirectory and total their sizes.  E.g., to *)
  7.   (* find all Pascal files, execute KILLIT *.PAS           *)
  8.   (********************************************************)
  9. USES DOS,CRT,Engine;
  10.  
  11. VAR
  12.   template, path : STRING;
  13.   ErrCode        : Byte;
  14.   Total          : LongInt;
  15.  
  16. {$F+} Procedure KillFile(VAR S : SearchRec; path : PathStr); {$F-}
  17. Var
  18.   TheFileName : String;
  19.   FileVar     : Text;
  20.   Ch          : Char;
  21.   X,Y         : Byte;
  22. Begin
  23.   TheFileName := path + S.Name;
  24.   Write(TheFileName); Write(' Kill This File (Y/N) ? ');
  25.   X := WhereX; Y := WhereY;
  26.   Repeat Ch := ReadKey; Ch := UpCase(Ch); Until Ch In['Y','N'];
  27.   GotoXY(X,Y); WriteLn(Ch);
  28.   If Ch = 'Y' Then
  29.   Begin
  30.     Assign(FileVar,TheFileName);
  31.     ReWrite(FileVar);
  32.     Close(FileVar);
  33.     Erase(FileVar);
  34.     Total := Total + S.Size
  35.   End;
  36. End;
  37.  
  38. Procedure Validate;
  39.   {Validate the command line parameter}
  40. VAR P : Byte;
  41.   Ext : ExtStr;
  42. Begin
  43.   If ParamCount <> 1 Then
  44.   Begin
  45.     WriteLn('SYNTAX:  "KILLIT [path]filespec"');
  46.     Halt;
  47.   End;
  48.   FSplit(ParamStr(1), path, template, Ext);
  49.   If Length(path) = 2 Then path := path + '\';
  50.   template := template + Ext;
  51.   (*If no path specIfied, search from root of
  52.   current volume*)
  53.   If path = '' Then
  54.   Begin
  55.     GetDir(0, path);
  56.     If Length(path) = 2 Then path := path + '\' Else path[0] := #3;
  57.   End;
  58. End;
  59.  
  60. Procedure SetScreen;
  61. Begin
  62.   TextColor(LightGray);
  63.   TextBackGround(Black);
  64.   ClrScr;
  65. End;
  66.  
  67. Procedure DoTheWork;
  68. Begin
  69.   WriteLn;
  70.   WriteLn('KILLIT.EXE : File Zapping Utility.');
  71.   WriteLn('Written by : William L. Mabee, CRNA');
  72.   WriteLn;
  73.   WriteLn('Searching for "', template, '" in or below "', path, '"');
  74.   WriteLn;
  75.   SearchEngineAll(path, template, Archive, KillFile, ErrCode);
  76.   WriteLn;
  77.   Writeln('File(s) occupied ',Total,' bytes of disk space.')
  78. End;
  79.  
  80. Begin
  81.   SetScreen;
  82.   Total := 0;
  83.   Validate;
  84.   DoTheWork;
  85. End.
  86.