You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Grigory Petrov <gr...@gmail.com> on 2011/03/02 09:29:09 UTC

What is the most simple way to use svn_stream_t?

Hello.

I need to programmatically get content of a specified revision of
versioned file. I think svn_client_cat2() will do a good job, but the
first parameter, "svn_stream_t* out" puzzles me a bit. I have read
about "streams" in corresponding header file (not a very long reading)
and it seems to be that using stream as output buffer for
svn_client_cat2() is terribly complicated: i need to create stream,
supply it to baton and read/write functions, write code for that
functions that will queue and dequeue bindary data to and from buffer
associated with baton... This seems to be a lot of code. Is it any way
to create a simple svn_stream_t* that will act as a memory buffer so i
can give it to svn_client_cat2() and on success just get all data
received as a single memory buffer?

Any comments and insights are welcome!

Best,
Grigory.

Re: What is the most simple way to use svn_stream_t?

Posted by Greg Stein <gs...@gmail.com>.
Use svn_stream_from_stringbuf(). That will put the contents of the
file into the stringbuf, which you can access after the cat2() call is
done.

NOTE: be very careful of reading file contents into memory. You really
don't want to try and read a 16 gigabyte file this way.

Cheers,
-g

On Wed, Mar 2, 2011 at 03:29, Grigory Petrov <gr...@gmail.com> wrote:
> Hello.
>
> I need to programmatically get content of a specified revision of
> versioned file. I think svn_client_cat2() will do a good job, but the
> first parameter, "svn_stream_t* out" puzzles me a bit. I have read
> about "streams" in corresponding header file (not a very long reading)
> and it seems to be that using stream as output buffer for
> svn_client_cat2() is terribly complicated: i need to create stream,
> supply it to baton and read/write functions, write code for that
> functions that will queue and dequeue bindary data to and from buffer
> associated with baton... This seems to be a lot of code. Is it any way
> to create a simple svn_stream_t* that will act as a memory buffer so i
> can give it to svn_client_cat2() and on success just get all data
> received as a single memory buffer?
>
> Any comments and insights are welcome!
>
> Best,
> Grigory.
>