Module: Svn::Stream::C
- Extended by:
- FFI::Library
- Defined in:
- lib/svn/streams.rb
Constant Summary collapse
- ReadFromIO =
note: the SVN docs say that short reads indicate the end of the stream and short writes indicate an error. this means that we cannot use read_nonblock and write_nonblock, since they do not guarantee anything will happen.
FFI::Function.new( :pointer, [:pointer, :pointer, :pointer] ) do |io_ptr, out_buffer, in_out_len| # read the number of bytes requested and unwrap the io object bytes_to_read = in_out_len.read_int io = Svn::Utils.unwrap(io_ptr) # read the bytes from IO and write them to the pointer object bytes_read = io.read( bytes_to_read ) out_buffer.write_string( bytes_read ) # write the number of bytes read from io in_out_len.write_int( bytes_read.length ) nil # return no error end
- WriteToIO =
FFI::Function.new( :pointer, [:pointer, :string, :pointer] ) do |io_ptr, in_string, in_out_len| # read the size of in_string and unwrap the io object bytes_to_write = in_out_len.read_int io = Svn::Utils.unwrap(io_ptr) # should we check that in_string isn't longer than in_out_len? bytes_written = io.write( in_string ) # write the actual number of bytes written to io in_out_len.write_int( bytes_written ) nil # return no error end