home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / pascal / 7603 < prev    next >
Encoding:
Text File  |  1992-12-21  |  3.7 KB  |  97 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!rpi!ghost.dsi.unimi.it!univ-lyon1.fr!cismibm.univ-lyon1.fr!ppollet
  2. From: ppollet@cismibm.univ-lyon1.fr (Patrick POLLET)
  3. Newsgroups: comp.lang.pascal
  4. Subject: Re: Copying Files directed by TP code
  5. Date: Mon, 21 Dec 1992 16:18:11 GMT
  6. Organization: INSA  CENTRE INFORMATIQUE DU 1er CYCLE
  7. Lines: 83
  8. Message-ID: <ppollet.83.724954691@cismibm.univ-lyon1.fr>
  9. References: <1992Dec20.161657.20863@oucsace.cs.ohiou.edu>
  10. NNTP-Posting-Host: 134.214.232.25
  11. Summary: copying filesies
  12. Keywords: DOS copy, copying files
  13.  
  14. In article <1992Dec20.161657.20863@oucsace.cs.ohiou.edu> csnyder@bobcat.ent.ohiou.edu (Chris Snyder  UNDER-ECE) writes:
  15. >From: csnyder@bobcat.ent.ohiou.edu (Chris Snyder  UNDER-ECE)
  16. >Subject: Copying Files directed by TP code
  17. >Summary: copying filesies
  18. >Keywords: DOS copy, copying files
  19. >Date: 20 Dec 92 16:16:57 GMT
  20.  
  21.  
  22. >I have tried using the EXEC command but I can't get it to work. Here is the 
  23. >command lines I have tried.
  24.  
  25. >EXEC('copy',name1+name2)   (* returns DOSERROR = 2 file not found  *)
  26.  
  27.     Not suprising . copy is n internal command of DOS and
  28.      not an EXE or COM file...
  29.  
  30. >EXEC('cpy.bat',name1+' '+name2)   (* locks up everything had to RESET  *)
  31. >                                  (* cpy.bat is a batch with
  32. >                                        copy %1 %2                     *)
  33.     Same reason. turbo tried to load a bat file as an executable
  34.     binary file....
  35.  
  36.      Copy and cpy.bat are commands that can only be processed by a 
  37. secondary copy of COMMAND.COM . Therefore you must call  COMMAND.COM
  38. and pass it as a parameter the command using the /C switch...
  39.  
  40.  
  41.    EXEC(GetEnv('COMSPEC','/C copy '+Name1+' '+Name2)
  42.         ^^^^ retrieves from environnment the full path to Command.com
  43.  
  44. >I also tried using the {$M} compiler directive to adjust the heap to various
  45. >sizes and then using the swapvectors procedure before and after the EXEC 
  46. >command, but I got the same results as above.
  47.    
  48.     YOU MUST ALSO DO THAT to have some memory left below your program 
  49. to let DOS load command.com and command.com to load or run 
  50. the command passed as a parameter.
  51.  
  52.  
  53. >Another posibility that I consdered was to copy the program with READ and 
  54. >WRITE. This works but is ungodly slow. I tried using various buffer sizes
  55. >and methods but the fastest speed that I could attain for copying a 60K file
  56. >from the HD to a 3.5 disk was about 24 sec, compared to doing it in DOS with
  57. >the copy command of 4 sec. That is not a good time ratio and will never do.
  58.  
  59.  
  60.     You should consider the fast Blockread/BlockWrite routines.
  61.   Something like:
  62.        
  63.         Var Buffer :array[1..16000] of Byte;
  64.             (* or more efficiently  uses a dynamic variable and a pointer
  65.                 to reduce usage of data segment or stack  *)
  66.             Fin,Fout:File;
  67.  
  68.           Assign (Fin,NameOfOriginalFile);
  69.           Reset(Fin,1);
  70.           Assign(Fout,NameOfCopy);
  71.           Rewrite(Fout,1);
  72.            
  73.            Repeat
  74.               Blockread(Fin,Buffer,Sizeof(Buffer),NbBytesReallyGot);
  75.               If nbBytesreallyGot >0 then BlockWrite(Fout,Buffer,
  76. nbBytesreallyGot);
  77.             until nbbytesreallyGot =0;
  78.            Close(Fin);Close(Fout)
  79.  
  80.        I did not make any measurment but this wille be definively faster 
  81. than 24 seconds for 60Kb    
  82.  
  83. Hope it helps....
  84.  
  85. Season greetings 
  86. ppollet@cismibm.univ-lyon1.fr (Patrick POLLET)
  87. --------------------------------------------------------
  88. Dr Patrick L.Pollet
  89. Institut National des Sciences Appliquées
  90. Centre Informatique du 1er Cycle  Bat 110
  91. 20 Avenue A.Einstein
  92. 69621 Villeurbanne Cedex France
  93. --------------------------------------------------------
  94. Phone: 72 43 83 80 -   la premiere erreur c'est
  95. Fax  : 72 43 85 33 -   de se lever le matin  ... GASTON
  96. -------------------------------------------------------
  97.