copystream             package:Rstreams             R Documentation

_C_o_p_y _f_r_o_m _O_n_e _S_t_r_e_a_m _t_o _A_n_o_t_h_e_r

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

     Copies bytes from the current position of one stream to the
     current position of another.

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

       copystream(src, dest, nbytes)

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

     src: a stream previously opened in read mode.

    dest: a stream previously opened in write mode.

  nbytes: how many bytes to copy

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

     If you request copying more bytes than are present in the source,
     values will not be repeated:  only what is there will be copied.

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

     how many bytes were actually copied.

_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)
     closestream(s)
     s1 <- openstream("mydata", "read")
     s2 <- openstream("newdata", "write")
     # Write a header in text, then copy the rest
     writechar(s2, "Header")
     copystream(s1, s2, summary(s1)$size)
     closestream(s1)
     closestream(s2)
     unlink(c("mydata", "newdata"))

