home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 8 / CDASC08.ISO / NEWS / 554 / JUIN / COPYIT.PAS < prev    next >
Pascal/Delphi Source File  |  1993-10-07  |  2KB  |  66 lines

  1. {─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
  2. Msg  : 528 of 587
  3. From : Todd Holmes                         1:152/5.0            06 Jun 93  08:42
  4. To   : Steve Mathieson                     1:163/319.0
  5. Subj : 2 Questions
  6. ────────────────────────────────────────────────────────────────────────────────
  7.  sm>2 Questions:
  8.  
  9.  sm>First off, has anyone got any FAST file copy routines using
  10.  sm>InLine ASM?
  11.  
  12. No fast as assembly, but *VERY* easy to use;}
  13.  
  14. {Little to No error checking!}
  15.  
  16. Program CopyIt;
  17.  
  18. Uses Objects;  {The Object unit is need to access TStream}
  19.  
  20. var
  21.     InFile,OutFile: Pstream;       {Pointer to TStream}
  22.  
  23. Function GetFileName: String; {Get the name of the file from the command       
  24. line}
  25. var FileName: String;
  26. begin
  27.   If ParamStr(2) = '' then FileName := ParamStr(1)
  28.   Else FileName := ParamStr(2);
  29.   GetFileName := FileName;
  30. end;
  31.  
  32. Function Opened(Var InFile: PStream; FileOne: String):Boolean;
  33. Var DosStream,EmsStream : PStream;
  34. begin
  35.   If ParamStr(1) <> '' then begin
  36.      DosStream := New(PBufStream,Init(ParamStr(1),StOpenRead);
  37.      If DosStream^.ErrorInfo <> StOk then begin
  38.         Writeln('Couldn't find the file');
  39.         Dispose(DosStream,Done);
  40.         Halt(1);
  41.     EmsStream := New(PEmsStream,Init(DosStream^.GetSize,DosStream^.GetSize);
  42.     {Creates an EmsStream the Size of the Dos File to copy}
  43.     If EmsStream^.ErrorInfo <> StOk then begin
  44.        Dispose(EmsStream,Done);
  45.        InFile := DosStream;
  46.       end
  47.     Else begin
  48.       EmsStream^.CopyFrom(DosStream,DosStream^.GetSize); {Copies file to Ems}
  49.       Dispose(DosStream,done);
  50.       InFile := EmsStream;     {InFile is now being copied form ems}
  51.      end
  52.     Opened := True
  53.   Else {If ParamStr(1) <> ''}
  54.     Opened := False;
  55. end; { Opened}
  56.  
  57. Begin
  58.   If Opened(InFile,ParamStr(1)) then begin   {Opens the InFile}
  59.     OutFile := New(PBufStream,Init(GetFileName,StCreate); (Open outFile)
  60.     OutFile^.CopyFrom(InFile,InFile^.GetSize);  {Copies to the OutFile}
  61.     Dispose(InFile,Done);
  62.     Dispose(OutFile,Done);
  63.    end
  64.   Else Writeln('Error proccessing file : ', Paramstr(1));
  65. end.
  66.