home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / ENGINE.ZIP / DIRSUM.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-01-14  |  992 b   |  29 lines

  1. {$R-,S+,I+,D+,F-,V-,B-,N-,L+ }
  2. {$M 2048,0,0 }
  3. PROGRAM DirSum;
  4.         (*******************************************************)
  5.         (* Uses SearchEngine to write the names of all files   *)
  6.         (* in the current directory and display the total disk *)
  7.         (* space that they occupy.                             *)
  8.         (*******************************************************)
  9. USES DOS,ENGINE;
  10.  
  11. VAR
  12.    Template  : PathStr;
  13.    ErrorCode : Byte;
  14.    Total     : LongInt;
  15.  
  16. {$F+} PROCEDURE WriteIt(VAR S : SearchRec; P : PathStr);  {$F-}
  17. BEGIN   WriteLn(S.name); Total := Total + S.Size END;
  18.  
  19. BEGIN
  20.      Total := 0;
  21.      GetDir(0, Template);
  22.      IF Length(Template) = 3 THEN Dec(Template[0]);
  23.      {^Avoid ending up with "C:\\*.*"!}
  24.      Template := Template + '\*.*';
  25.      SearchEngine(Template, AnyFile, WriteIt, ErrorCode);
  26.      IF ErrorCode <> 0 THEN ErrorMessage(ErrorCode) ELSE
  27.         WriteLn('Total size of displayed files: ', Total : 8);
  28. END.
  29.