home bbs files messages ]

Just a sample of the Echomail archive

Cooperative anarchy at its finest, still active today. Darkrealms is the Zone 1 Hub.

   PASCAL      Pascal programming language discussions      592 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 553 of 592   
   ATREYU to Chad Adams   
   Re: Copy File   
      
   
   MSGID: 1:229/426 FD835021   
   REPLY: 1:19/37 5bfc6e37   
   On 02 Sep 22  21:22:49, Chad Adams said the following to All:   
      
   CA> Does anyone know a function that will allow you to copy one file to another   
   CA> location?   
   CA>    
   CA> CopyFile(File, File2);   
      
   procedure SAFECOPY (fromFile, toFile : string);   
     type bufferType = array [1..64] of char;   
     type bufferTypePtr = ^bufferType;  { Use the heap }   
     var bufferPtr : bufferTypePtr;     { for the buffer }   
         f1, f2 : file;   
         bufferSize, readCount, writeCount : word;   
         fmSave : byte;              { To store the filemode }   
     begin   
       bufferSize := SizeOf(bufferType);   
       New (bufferPtr);              { Create the buffer, on the heap }   
       fmSave := FileMode;           { Store the filemode }   
       FileMode := 0;                { To read also read-only files }   
       Assign (f1, fromFile);   
       {$I-} Reset (f1, 1);          { Note the record size 1, important! }   
       if IOResult <> 0 then exit;   { Does the file exist? }   
       Assign (f2, toFile);   
       {$I-} Rewrite (f2, 1);        { Open the target }   
       if IOResult <> 0 then exit;   
       repeat                        { Do the copying }   
         BlockRead (f1, bufferPtr^, bufferSize, readCount);   
         {$I-} BlockWrite (f2, bufferPtr^, readCount, writeCount);         
         if IOResult <> 0 then begin close (f1); exit; end;   
       until (readCount = 0) or (writeCount <> readCount);   
       close (f1); close (f2);   
       FileMode := fmSave;           { Restore the original filemode }   
       Dispose (bufferPtr);          { Release the buffer from the heap }   
     end;  (* safecopy *)   
      
   Nick   
      
   --- Renegade vY2Ka2   
    * Origin: Joey, do you like movies about gladiators? (1:229/426)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca