Reading whole streams

As a convenience function, MuPDF provides a mechanism for reading the entire contents of a stream into a fz_buffer.


\begin{lstlisting}
/*
fz_read_all: Read all of a stream into a buffer.
\par
stm...
... *fz_read_all(fz_context *ctx, fz_stream *stm, size_t initial);
\end{lstlisting}

This will throw an error (and hence not return any data) if an error is encountered during the decode of the stream. Sometimes it can be preferable to `do the best we can' and tolerate problematic data. For such cases, we provide fz_read_best:


\begin{lstlisting}
/*
fz_read_best: Attempt to read a stream into a buffer. If ...
..._context *ctx, fz_stream *stm, size_t initial, int *truncated);
\end{lstlisting}