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