commit e2ed5908ea4b0e001e5f6176443995a7c14d0b28
parent ecc24235e4bfd156ca28aadbaeb4dc6e0db8024a
Author: Sebastian <sebastian@sebsite.pw>
Date: Sat, 9 Dec 2023 21:17:52 -0500
io: improve seek and whence docs
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/io/handle.ha b/io/handle.ha
@@ -50,7 +50,8 @@ export fn close(h: handle) (void | error) = {
};
};
-// Sets the offset within a [[handle]].
+// Sets the offset within a [[handle]], returning the new offset. The new offset
+// is obtained by adding [[off]] to the position specified by [[whence]].
export fn seek(h: handle, off: off, w: whence) (off | error) = {
match (h) {
case let fd: file =>
diff --git a/io/types.ha b/io/types.ha
@@ -33,9 +33,9 @@ export type mode = enum u8 {
// From "whence" a seek operation should occur.
export type whence = enum {
- SET = 0,
- CUR = 1,
- END = 2,
+ SET = 0, // Relative to beginning (i.e. set absolute position).
+ CUR = 1, // Relative to current position.
+ END = 2, // Relative to end of handle.
};
// The interface for a stream which can be read from. Reads up to len(buf)