PreviousUpNext

15.4.113  src/app/makelib/stuff/seek.pkg

## seek.pkg

# Compiled by:
#     src/app/makelib/stuff/makelib-stuff.sublib


# Seek in an Input_Stream.


api Seek {
    #
    exception UNABLE_TO_SEEK;

    seek:  (data_file__premicrothread::Input_Stream,  file_position::Int)
           ->
           Void;
};

package seek
:       Seek                                            # Seek  is from   src/app/makelib/stuff/seek.pkg
{
    exception UNABLE_TO_SEEK;

    empty_vector
        =
        vector_of_one_byte_unts::from_list [];
    
    fun seek (stream, position)
        =
        {   fs =  data_file__premicrothread::get_instream  stream;
            #
            my (reader, _)
                =
                data_file__premicrothread::pur::get_reader  fs;

            reader ->   winix_base_data_file_io_driver_for_posix__premicrothread::FILEREADER { set_file_position, ... };
        
            case set_file_position
                #             
                THE set_file_position
                    =>
                    {   set_file_position  position;
                        #
                        fs' =  data_file__premicrothread::pur::make_instream (reader, empty_vector);
                        #
                        data_file__premicrothread::set_instream (stream, fs');
                    };
                #
                NULL =>  raise exception UNABLE_TO_SEEK;
            esac;
        };
};

## (C) 1999 Lucent Technologies, Bell Laboratories
## Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2013,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext