seekstream             package:Rstreams             R Documentation

_S_e_t _B_i_n_a_r_y _S_t_r_e_a_m _t_o _N_e_w _P_o_s_i_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     Sets a binary stream to a new position.

_U_s_a_g_e:

       seekstream(stream, offset, origin = "start")

_A_r_g_u_m_e_n_t_s:

  stream: a previously opened stream.

  offset: the offset to seek to.

  origin: the base to which to apply offset.

_D_e_t_a_i_l_s:

     The origin may be `"start"', in which case offset is relative to
     the start of the file, `"current"', in which case it is relative
     to the current position, or `"end"', in which case it is relative
     to the end of the file.

_V_a_l_u_e:

     The new position of the stream.

_S_e_e _A_l_s_o:

     `openstream'

_E_x_a_m_p_l_e_s:

     s <- openstream("mydata", "write")
     # Write the bytes from 1 to 100 to the file
     writeint(s, 1:100, 1)
     # Write the bytes from 1 to 10 to the last 10 bytes of the file
     seekstream(s, -10, "end")
     writeint(s, 1:10, 1)
     closestream(s)
     s <- openstream("mydata", "read")
     readint(s, 100, 1)
     closestream(s)
     unlink("mydata")

