*/
Are you blogging on PH? Get your free blog.
*/

View \DELBAK.PAS

Uses SearchEngine to find and delete all *.BAK files in any

Submitted By: WEBMASTER
Rating: (Not rated) (Rate It)


PROGRAM DelBak; { An example program for ENGINE.TPU }

{$R-,S+,I+,D+,F-,V-,B-,N-,L+}
{$M $4000,0,0}

{*********************************************************}
{*                                                       *}
{*  Uses SearchEngine to find and delete all *.BAK files *}
{*  in any subdirectory in the current volume.           *}
{*                                                       *}
{*  Taken from Turbo Technix #6, 1988.                   *}
{*                                                       *}
{*  Originally written by                                *}
{*     Neil Rubenking                                    *}
{*                                                       *}
{*  Compiled and rewritten by                            *}
{*     Jens Bruun, Borland Scandinavia                   *}
{*                                                       *}
{*********************************************************}

USES DOS, ENGINE;

VAR
   Path    : PathStr;
   ErrCode : BYTE;
   Number  : INTEGER;
   Size    : LONGINT;

{$F+} PROCEDURE DelFile(VAR S: SearchRec; P: PathStr); {$F-}
VAR
   F: FILE;
BEGIN
   Inc(Size,S.size);
   Assign(F,P+S.name);
   WRITE('Deleting ',P+S.name,'... ');
   Erase(F);
   WRITELN('Done');
   Inc(Number);
END;

PROCEDURE Initialize;
BEGIN
   Number:=0;
   Size:=0;
   GetDir(0,Path);
   IF Length(Path)=2 THEN
      Path:=Path+'\'
   ELSE
      Path[0]:=#3;
   WRITELN('Going to delete ALL *.BAK files in the current volume.');
   WRITELN('Press <RETURN> to proceed, <Ctrl><Break> to stop.');
   READLN;
END;

BEGIN
   Initialize;
   SearchEngineAll(Path,'*.BAK',ANYFILE,DelFile,ErrCode);
   WRITELN;
   IF ErrCode<>0 THEN
      ErrorMessage(ErrCode)
   ELSE
      WRITELN('Erased ',Number,' *.BAK file(s) for a saving of ',Size,' Bytes');
END.

corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.