1 \ tag: deblocker support package
3 \ Copyright (C) 2003 Stefan Reinauer
5 \ See the file "COPYING" for further information about
6 \ the copyright and warranty status of this work.
9 " /packages" find-device
11 \ The deblocker package makes it easy to implement byte-oriented device
12 \ methods, using the block-oriented or record-oriented methods defined by
13 \ devices such as disks or tapes. It provides a layer of buffering between
14 \ the high-level byte-oriented interface and the low-level block-oriented
15 \ interface. deblocker uses the max-transfer, block-size, read-blocks and
16 \ write-blocks methods of its parent.
19 " deblocker" device-name
21 \ Prepares the package for subsequent use, allocating the buffers used
22 \ by the deblocking process based upon the values returned by the parent
23 \ instance's max-transfer and block-size methods. Returns -1 if the
24 \ operation succeeds, 0 otherwise.
30 \ Frees all resources that were allocated by open.
34 \ read ( adr len -- actual )
35 \ Reads at most len bytes from the device into the memory buffer
36 \ beginning at adr. Returns actual, the number of bytes actually
37 \ read, or 0 if the read operation failed. Uses the parent's read-
38 \ blocks method as necessary to satisfy the request, buffering any
39 \ unused bytes for the next request.
41 : read ( adr len -- actual )
44 \ Writes at most len bytes from the device into the memory buffer
45 \ beginning at adr. Returns actual, the number of bytes actually
46 \ read, or 0 if the write operation failed. Uses the parent's write-
47 \ blocks method as necessary to satisfy the request, buffering any
48 \ unused bytes for the next request.
50 : write ( adr len -- actual )
53 \ Sets the device position at which the next read or write will take
54 \ place. The position is specified by the 64-bit number x.position.
55 \ Returns 0 if the operation succeeds or -1 if it fails.
57 : seek ( x.position -- flag )