ChunkedFile reads and writes files which contain interleaved chunks of compressed and uncompressed data. More...
#include <chunked_file.h>
Public Member Functions | |
ChunkedFile () | |
void | close () |
close the file | |
void | decompress (CompressionType compression, uint8_t *dest, unsigned int dest_len, uint8_t *source, unsigned int source_len) |
uint32_t | getCompressedBytesIn () const |
return the number of bytes written to current compressed stream | |
std::string | getFileName () const |
return path of currently open file | |
std::string | getline () |
uint64_t | getOffset () const |
return current offset from the beginning of the file | |
bool | good () const |
return true if hasn't reached end-of-file and no error | |
bool | isOpen () const |
return true if file is open for reading or writing | |
void | openRead (std::string const &filename) |
open file for reading | |
void | openReadWrite (std::string const &filename) |
open file for reading & writing | |
void | openWrite (std::string const &filename) |
open file for writing | |
void | read (void *ptr, size_t size) |
read size bytes from the file into ptr | |
void | seek (uint64_t offset, int origin=std::ios_base::beg) |
seek to given offset from origin | |
void | setReadMode (CompressionType type) |
void | setWriteMode (CompressionType type) |
bool | truncate (uint64_t length) |
void | write (std::string const &s) |
void | write (void *ptr, size_t size) |
write size bytes from ptr to the file | |
~ChunkedFile () | |
Private Member Functions | |
void | clearUnused () |
void | open (std::string const &filename, std::string const &mode) |
Private Attributes | |
uint64_t | compressed_in_ |
number of bytes written to current compressed stream | |
FILE * | file_ |
file pointer | |
std::string | filename_ |
path to file | |
int | nUnused_ |
number of bytes of extra data read by compressed stream | |
uint64_t | offset_ |
current position in the file | |
boost::shared_ptr< Stream > | read_stream_ |
boost::shared_ptr< StreamFactory > | stream_factory_ |
char * | unused_ |
extra data read by compressed stream | |
boost::shared_ptr< Stream > | write_stream_ |
bool | writing_ |
true iff file is opened for writing | |
Friends | |
class | Stream |
ChunkedFile reads and writes files which contain interleaved chunks of compressed and uncompressed data.
Definition at line 51 of file chunked_file.h.
Definition at line 50 of file chunked_file.cpp.
Definition at line 60 of file chunked_file.cpp.
void rosbag::ChunkedFile::clearUnused | ( | ) | [private] |
Definition at line 189 of file chunked_file.cpp.
void rosbag::ChunkedFile::close | ( | ) |
close the file
Definition at line 103 of file chunked_file.cpp.
void rosbag::ChunkedFile::decompress | ( | CompressionType | compression, |
uint8_t * | dest, | ||
unsigned int | dest_len, | ||
uint8_t * | source, | ||
unsigned int | source_len | ||
) |
Definition at line 185 of file chunked_file.cpp.
uint32_t rosbag::ChunkedFile::getCompressedBytesIn | ( | ) | const |
return the number of bytes written to current compressed stream
Definition at line 161 of file chunked_file.cpp.
string rosbag::ChunkedFile::getFileName | ( | ) | const |
return path of currently open file
Definition at line 101 of file chunked_file.cpp.
string rosbag::ChunkedFile::getline | ( | ) |
Definition at line 173 of file chunked_file.cpp.
uint64_t rosbag::ChunkedFile::getOffset | ( | ) | const |
return current offset from the beginning of the file
Definition at line 160 of file chunked_file.cpp.
bool rosbag::ChunkedFile::good | ( | ) | const |
return true if hasn't reached end-of-file and no error
Definition at line 96 of file chunked_file.cpp.
bool rosbag::ChunkedFile::isOpen | ( | ) | const |
return true if file is open for reading or writing
Definition at line 100 of file chunked_file.cpp.
void rosbag::ChunkedFile::open | ( | std::string const & | filename, |
std::string const & | mode | ||
) | [private] |
Definition at line 68 of file chunked_file.cpp.
void rosbag::ChunkedFile::openRead | ( | std::string const & | filename | ) |
open file for reading
Definition at line 66 of file chunked_file.cpp.
void rosbag::ChunkedFile::openReadWrite | ( | std::string const & | filename | ) |
open file for reading & writing
Definition at line 64 of file chunked_file.cpp.
void rosbag::ChunkedFile::openWrite | ( | std::string const & | filename | ) |
open file for writing
Definition at line 65 of file chunked_file.cpp.
void rosbag::ChunkedFile::read | ( | void * | ptr, |
size_t | size | ||
) |
read size bytes from the file into ptr
Definition at line 165 of file chunked_file.cpp.
void rosbag::ChunkedFile::seek | ( | uint64_t | offset, |
int | origin = std::ios_base::beg |
||
) |
seek to given offset from origin
Definition at line 147 of file chunked_file.cpp.
void rosbag::ChunkedFile::setReadMode | ( | CompressionType | type | ) |
Definition at line 135 of file chunked_file.cpp.
void rosbag::ChunkedFile::setWriteMode | ( | CompressionType | type | ) |
Definition at line 123 of file chunked_file.cpp.
bool rosbag::ChunkedFile::truncate | ( | uint64_t | length | ) |
Definition at line 167 of file chunked_file.cpp.
void rosbag::ChunkedFile::write | ( | std::string const & | s | ) |
void rosbag::ChunkedFile::write | ( | void * | ptr, |
size_t | size | ||
) |
write size bytes from ptr to the file
Definition at line 164 of file chunked_file.cpp.
friend class Stream [friend] |
Definition at line 53 of file chunked_file.h.
uint64_t rosbag::ChunkedFile::compressed_in_ [private] |
number of bytes written to current compressed stream
Definition at line 92 of file chunked_file.h.
FILE* rosbag::ChunkedFile::file_ [private] |
file pointer
Definition at line 89 of file chunked_file.h.
std::string rosbag::ChunkedFile::filename_ [private] |
path to file
Definition at line 88 of file chunked_file.h.
int rosbag::ChunkedFile::nUnused_ [private] |
number of bytes of extra data read by compressed stream
Definition at line 94 of file chunked_file.h.
uint64_t rosbag::ChunkedFile::offset_ [private] |
current position in the file
Definition at line 91 of file chunked_file.h.
boost::shared_ptr<Stream> rosbag::ChunkedFile::read_stream_ [private] |
Definition at line 98 of file chunked_file.h.
boost::shared_ptr<StreamFactory> rosbag::ChunkedFile::stream_factory_ [private] |
Definition at line 96 of file chunked_file.h.
char* rosbag::ChunkedFile::unused_ [private] |
extra data read by compressed stream
Definition at line 93 of file chunked_file.h.
boost::shared_ptr<Stream> rosbag::ChunkedFile::write_stream_ [private] |
Definition at line 99 of file chunked_file.h.
bool rosbag::ChunkedFile::writing_ [private] |
true iff file is opened for writing
Definition at line 90 of file chunked_file.h.