Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/cm/util/seek.sml
ViewVC logotype

Annotation of /sml/trunk/src/cm/util/seek.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 651 - (view) (download)

1 : blume 295 (*
2 :     * Seek in an instream.
3 :     *
4 :     * (C) 1999 Lucent Technologies, Bell Laboratories
5 :     *
6 :     * Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
7 :     *)
8 :     signature SEEK = sig
9 :    
10 :     exception UnableToSeek
11 :    
12 :     val seek : BinIO.instream * int -> unit
13 :     end
14 :    
15 :     structure Seek :> SEEK = struct
16 :    
17 :     exception UnableToSeek
18 :    
19 :     val emptyVector = Word8Vector.fromList []
20 :    
21 :     fun seek (s, pos) = let
22 :     val fs = BinIO.getInstream s
23 :     val (r, _) = BinIO.StreamIO.getReader fs
24 :     val BinPrimIO.RD { setPos, ... } = r
25 :     in
26 :     case setPos of
27 :     NONE => raise UnableToSeek
28 :     | SOME sp => let
29 :     val _ = sp pos
30 :     val fs' = BinIO.StreamIO.mkInstream (r, emptyVector)
31 :     in
32 :     BinIO.setInstream (s, fs')
33 :     end
34 :     end
35 :     end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0