|
|
1.1 ! root 1: \ tag: deblocker support package ! 2: \ ! 3: \ Copyright (C) 2003 Stefan Reinauer ! 4: \ ! 5: \ See the file "COPYING" for further information about ! 6: \ the copyright and warranty status of this work. ! 7: \ ! 8: ! 9: " /packages" find-device ! 10: ! 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. ! 17: ! 18: new-device ! 19: " deblocker" device-name ! 20: \ open ( -- flag ) ! 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. ! 25: : open ( -- flag ) ! 26: ! 27: ; ! 28: ! 29: \ close ( -- ) ! 30: \ Frees all resources that were allocated by open. ! 31: : close ( -- ) ! 32: ; ! 33: ! 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. ! 40: ! 41: : read ( adr len -- actual ) ! 42: ; ! 43: ! 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. ! 49: ! 50: : write ( adr len -- actual ) ! 51: ; ! 52: ! 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. ! 56: ! 57: : seek ( x.position -- flag ) ! 58: ; ! 59: ! 60: finish-device ! 61: ! 62: \ clean up afterwards ! 63: device-end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.