Project

General

Profile

Bread » History » Version 7

Per Amundsen, 12/13/2019 06:07 PM

1 1 Per Amundsen
_Added in 1.9.0_
2
3 6 Per Amundsen
*/bread [-ta] <filename> <S> <N> <&binvar>*
4 1 Per Amundsen
5
Reads <N> bytes starting at byte position <S> in the file and stores the result in &binvar.
6
7
*Switches*
8
9 7 Per Amundsen
-t - reads data until the next [[$crlf]] or [[$feof]].
10 6 Per Amundsen
-a - Disables UTF-8 encoding of characters in the range 0-255, as long as the line contains no characters > 255.
11 1 Per Amundsen
12
*Parameters*
13
14
<filename> - The binary file to read.
15 3 Per Amundsen
<S> - The byte position in the file to start reading from.
16 1 Per Amundsen
<N> - Number of bytes to read.
17
<&binvar> - The &binvar to read the data into.
18
19
*Example*
20
21 2 Per Amundsen
<pre>
22 1 Per Amundsen
;noop $example(FileA, FileB)
23
alias example {
24
   ;Read the whole file into a binary variable
25
   bread $qt($1) 0 $file($1).size &tempFile
26
 
27
   ;Write the bytes form the binary variable to a file
28
   bwrite $qt($2) 0 -1 &tempFile
29
}
30 2 Per Amundsen
</pre>