Turi Create
4.0
|
#include <core/storage/fileio/cache_stream_source.hpp>
Public Member Functions | |
cache_stream_source (cache_id_type cache_id) | |
std::streamsize | read (char *c, std::streamsize bufsize) |
void | close () |
bool | is_open () const |
std::streampos | seek (std::streamoff off, std::ios_base::seekdir way) |
size_t | file_size () const |
std::shared_ptr< std::istream > | get_underlying_stream () |
A boost::iostreams::input_seekable concept implemented using cache_block as the underlying source device.
Definition at line 23 of file cache_stream_source.hpp.
|
explicit |
Construct the source from a cache_id.
Intialize the underlying datasources, either the in memory array or the on disk cache file.
void turi::fileio_impl::cache_stream_source::close | ( | ) |
Closes all file handles.
size_t turi::fileio_impl::cache_stream_source::file_size | ( | ) | const |
Returns the file size of the opened file. Returns (size_t)(-1) if there is no file opened, or if there is an error obtaining the file size.
std::shared_ptr<std::istream> turi::fileio_impl::cache_stream_source::get_underlying_stream | ( | ) |
Returns the underlying stream object. The underlying stream object is an boost array_source if the cache is in memory, and is a some other stream object otherwise.
bool turi::fileio_impl::cache_stream_source::is_open | ( | ) | const |
Returns true if the stream is opened.
std::streamsize turi::fileio_impl::cache_stream_source::read | ( | char * | c, |
std::streamsize | bufsize | ||
) |
Attempts to read bufsize bytes into the buffer provided. Returns the actual number of bytes read.
std::streampos turi::fileio_impl::cache_stream_source::seek | ( | std::streamoff | off, |
std::ios_base::seekdir | way | ||
) |
Seeks to a different location. Will fail on compressed files.