Turi Create
4.0
|
#include <core/storage/fileio/general_fstream_sink.hpp>
Public Member Functions | |
general_fstream_sink (std::string file) | |
general_fstream_sink (std::string file, bool gzip_compressed) | |
general_fstream_sink (const general_fstream_sink &)=default | |
general_fstream_sink (general_fstream_sink &&)=default | |
~general_fstream_sink () | |
Destructor. Closes the file. | |
bool | is_open () const |
std::streamsize | write (const char *c, std::streamsize bufsize) |
void | close () |
bool | good () const |
bool | bad () const |
bool | fail () const |
size_t | get_bytes_written () const |
Implements a general file stream sink device which wraps the union_fstream, and provides automatic gzip decompression capabilities.
The general_fstream_sink is NOT thread-safe.
Definition at line 26 of file general_fstream_sink.hpp.
|
explicit |
Constructs a fstream sink which write to a file. This file can be of any protocol supported by the union_fstream, and may also be gzip compressed. Gzip compression detection is automatic based on the file extension. (Whether it ends in .gz)
turi::fileio_impl::general_fstream_sink::general_fstream_sink | ( | std::string | file, |
bool | gzip_compressed | ||
) |
Constructs a fstream sink which writes to a file. This file can be of any protocol supported by the union_fstream, and may also be gzip compressed. Gzip compression detection is not performed, and the gzip_compressed flag is used to enable/disable gzip decompression.
|
default |
Default copy constructor. copied object shares handles with the original object. Required because boost streams requires devices to be copyable. This should really not be used otherwise.
|
default |
Default move constructor
bool turi::fileio_impl::general_fstream_sink::bad | ( | ) | const |
Returns true if the stream is bad. See std::ios_base
void turi::fileio_impl::general_fstream_sink::close | ( | ) |
Closes all file handles
bool turi::fileio_impl::general_fstream_sink::fail | ( | ) | const |
Returns true if a stream operation failed. See std::ios_base
size_t turi::fileio_impl::general_fstream_sink::get_bytes_written | ( | ) | const |
Returns the number of physical bytes written so far. This is an estimate, especially if the file is gzip compressed. Returns (size_t)(-1) if there is no file opened.
bool turi::fileio_impl::general_fstream_sink::good | ( | ) | const |
Returns true if the stream is good. See std::ios_base
bool turi::fileio_impl::general_fstream_sink::is_open | ( | ) | const |
Returns true if the file is opened
std::streamsize turi::fileio_impl::general_fstream_sink::write | ( | const char * | c, |
std::streamsize | bufsize | ||
) |
Attempts to write bufsize bytes into the stream from the buffer. Returns the actual number of bytes read. Returns -1 on failure.