[m-rev.] diff: add seek with 64-bit offsets to seekable/2 type class

Julien Fischer jfischer at opturion.com
Mon Oct 7 13:59:58 AEDT 2019


This builds on the diff I posted on Friday.

-------------------------------------------------------------

Add seek with 64-bit offsets to seekable/2 type class.

library/stream.m:
      As above.

library/io.m:
      Update the seekable/2 instances for binary input and
      output streams.

diff --git a/library/io.m b/library/io.m
index 7c3d896..2938d48 100644
--- a/library/io.m
+++ b/library/io.m
@@ -14085,6 +14085,10 @@ result_to_stream_result(error(Error)) = error(Error).
      ( seek(Stream, Whence0, OffSet, !IO) :-
          Whence = stream_whence_to_io_whence(Whence0),
          seek_binary_input(Stream, Whence, OffSet, !IO)
+    ),
+    ( seek64(Stream, Whence0, OffSet, !IO) :-
+        Whence = stream_whence_to_io_whence(Whence0),
+        seek64_binary_input(Stream, Whence, OffSet, !IO)
      )
  ].

@@ -14155,6 +14159,10 @@ res_to_stream_res(error(E)) = error(E).
      ( seek(Stream, Whence0, OffSet, !IO) :-
          Whence = stream_whence_to_io_whence(Whence0),
          seek_binary_output(Stream, Whence, OffSet, !IO)
+    ),
+    ( seek64(Stream, Whence0, Offset, !IO) :-
+        Whence = stream_whence_to_io_whence(Whence0),
+        seek64_binary_output(Stream, Whence, Offset, !IO)
      )
  ].

diff --git a/library/stream.m b/library/stream.m
index 2b04357..27356fa 100644
--- a/library/stream.m
+++ b/library/stream.m
@@ -260,7 +260,11 @@
      % Seek to an offset relative to whence on the specified stream.
      % The offset is measured in bytes.
      %
-    pred seek(Stream::in, whence::in, int::in, State::di, State::uo) is det
+    pred seek(Stream::in, whence::in, int::in, State::di, State::uo) is det,
+
+    % As above, but the offset is always a 64-bit value.
+    %
+    pred seek64(Stream::in, whence::in, int64::in, State::di, State::uo) is det
  ].

  %---------------------------------------------------------------------------%



More information about the reviews mailing list