I had some time this evening so here it is in the extract directory:
https://drive.google.com/file/d/0B6XhJJ … sp=sharing
Extract bytes from a file :-
.extract file [+off][-off][len]
[-f] [-o outfile] [-a outfile]
[-p byte] [-m address]
file = input filename
+off = byte offset from start
-off = byte offset from end
len = length in bytes
-f = overwrite permitted
-p = pad if input < len
-o = write to output file
-a = append to output file
-m = copy to memory address
no -o,-a,-m generates hexdump
Specify the input file, optionally the initial byte offset into the file (- = from the end of the file) and optionally the length in bytes (default is to the end of the file)
-a outfile to append to an existing file *****
-o outfile to create a new file
-f to allow overwriting an existing file with -o
-m address to send bytes to the memory address
(padding is disabled atm)
If there is no -a,-o,-m then a hexdump is done instead.
All numbers can be hex, decimal or octal.
;; load screen$ from an sna
.extract game.sna +27 6912 -m 0x4000
;; have a look at the sna header in a hexdump
.extract game.sna 27
;; copy the last 100 bytes to a file
.extract readme.txt -100 -o tail.txt
;; see a hexdump
**** I cannot test append because the emulators do not fully emulate esxdos.
Because I can only test on emulators, you should do some testing of your own to make sure things work.
Jim Bagley posted that there is a bug in esxdos that does not allow seeks to occur unless a previous read or write has happened. So int he code I am doing things like this:
esxdos_f_read(fout, buffer, 1); // reported bug: esxdos cannot seek unless r/w has occurred first
esxdos_f_seek(fout, st.size, ESXDOS_SEEK_SET);
so that a file is opened, 1 byte is read, and then the seek to wanted position happens.