Copy
Description
This command will copy data from an open file to another open file. Requirements: Two files must be open, one for reading, and the second for writing.
e.g.
O 1 R /sourcefile.txt
O 2 RW /destfile.txt
Copy File will copy from the current location in the source file, up to “num” bytes if specified, to the destination file (starting at the destination’s current location).
NOTE: You can interrupt the transfer at any time by sending «ESC»
(ASCII 27, HEX 0x1B).
Format
B
fh1
fh2
[num]
Parameters
fh1
andfh2
are file handles (1 - 4). Use the Free Handle command to get a free file handle.num
is the number of bytes to copy fromfh1
tofh2
. Ifnum
is not given, or is greater than the size offh1
, then the entire contents offh1
is copied.
Response Format
NULL | Copy successful (setting C = 0) |
response | Copy successful (see below) |
Enn | An error occurred |
response
depends on the C
setting shown below.
C = 0 | NULL |
C = 1 | #########...#### |
C = 2 | nn..nn bytes copied at r..rr bytes/second |
C = 3 | #####...####nn..nn bytes copied at r..rr bytes/second |
Example
To copy 200 bytes from the current location of handle 1 to handle 2:
B 1 2 200
To copy the entire source file to the destination file:
O 1 R /sourcefile.txt
O 2 RW /destfile.txt
B 1 2
To copy 600 bytes from position 12000 of handle 1, to handle 3, starting at position 50000:
O 1 R /sourcefile.txt
O 3 RW /destfile.txt
J 1 12000
J 3 50000
B 1 3 600
To copy the entirety of handle 1 to the end of handle 2 (appended):
O 1 R /sourcefile.txt
O 2 RW /destfile.txt
J 2 E
B 1 2
or (note that the destination file is opened for append)
O 1 R /sourcefile.txt
O 2 A /destfile.txt
B 1 2