summaryrefslogtreecommitdiffstats
path: root/gambit.init
diff options
context:
space:
mode:
Diffstat (limited to 'gambit.init')
-rw-r--r--gambit.init32
1 files changed, 32 insertions, 0 deletions
diff --git a/gambit.init b/gambit.init
index 07841e6..e431160 100644
--- a/gambit.init
+++ b/gambit.init
@@ -243,6 +243,38 @@
(define (offset-time caltime offset)
(seconds->time (+ (time->seconds caltime) offset)))
+;; procedure: input-port-byte-position port [position [whence]]
+;; procedure: output-port-byte-position port [position [whence]]
+;;
+;; When called with a single argument these procedures return the
+;; byte position where the next I/O operation would take place in the
+;; file attached to the given port (relative to the beginning of the
+;; file). When called with two or three arguments, the byte position
+;; for subsequent I/O operations on the given port is changed to
+;; position, which must be an exact integer. When whence is omitted
+;; or is 0, the position is relative to the beginning of the file.
+;; When whence is 1, the position is relative to the current byte
+;; position of the file. When whence is 2, the position is relative
+;; to the end of the file. The return value is the new byte position.
+;; On most operating systems the byte position for reading and writing
+;; of a given bidirectional port are the same.
+;;
+;; When input-port-byte-position is called to change the byte
+;; position of an input-port, all input buffers will be flushed so
+;; that the next byte read will be the one at the given position.
+;;
+;; When output-port-byte-position is called to change the byte
+;; position of an output-port, there is an implicit call to
+;; force-output before the position is changed.
+
+;;@ (FILE-POSITION <port> . <k>)
+(define (file-position port . k)
+ (apply (if (output-port? port)
+ output-port-byte-position
+ input-port-byte-position)
+ port
+ k))
+
;;; (OUTPUT-PORT-WIDTH <port>)
;; (define (output-port-width . arg) 79)