home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue61 / Alfresco / Unit1.pas < prev   
Encoding:
Pascal/Delphi Source File  |  2000-08-08  |  1.1 KB  |  63 lines

  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     procedure Button1Click(Sender: TObject);
  13.   private
  14.     { Private declarations }
  15.   public
  16.     { Public declarations }
  17.   end;
  18.  
  19. var
  20.   Form1: TForm1;
  21.  
  22. implementation
  23.  
  24. {$R *.DFM}
  25.  
  26. uses
  27.   AAPriQue, AAHshLnP, AACache;
  28.  
  29. procedure TForm1.Button1Click(Sender: TObject);
  30. var
  31.   Cache : TaaFileCache;
  32.   SR    : TSearchRec;
  33.   Error : integer;
  34.   FS    : TFileStream;
  35.   FullName : string;
  36. begin
  37.   Cache := TaaFileCache.Create;
  38.   try
  39.     Cache.Folder := 'c:\temp';
  40.     Cache.MaxDiskSize := 130 * 1024;
  41.  
  42.     Error := FindFirst ('.\aa*.pas', faAnyFile, SR);
  43.     if (Error = 0) then begin
  44.       while (Error = 0) do begin
  45.         FullName := ExpandFileName(SR.Name);
  46.         FS := TFileStream.Create(FullName, fmOpenRead+fmShareDenyWrite);
  47.         try
  48.           Cache.Add(FullName, Now, FS);
  49.         finally
  50.           FS.Free;
  51.         end;
  52.         Error := FindNext(SR);
  53.       end;
  54.       FindClose(SR);
  55.     end;
  56.  
  57.   finally
  58.     Cache.Free;
  59.   end;
  60. end;
  61.  
  62. end.
  63.