44 # define fseeko fseeko64 45 # define ftello ftello64 49 # define fseeko _fseeki64 50 # define ftello _ftelli64 51 # define fileno _fileno 52 # define ftruncate _chsize_s //Intel Realsense Change, Was: #define ftruncate _chsize 58 using std::shared_ptr;
89 #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) 90 fopen_s( &
file_, filename.c_str(),
"r" );
92 file_ = fopen(filename.c_str(),
"r");
96 #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) 97 fopen_s( &file_, filename.c_str(),
"w+b" );
99 file_ = fopen(filename.c_str(),
"w+b");
104 #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) 105 fopen_s( &file_, filename.c_str(),
"r+b" );
107 file_ = fopen(filename.c_str(),
"r+b");
112 #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) 113 fopen_s( &
file_, filename.c_str(), mode.c_str() );
115 file_ = fopen(filename.c_str(), mode.c_str());
121 read_stream_ = std::make_shared<UncompressedStream>(
this);
128 return feof(
file_) == 0 && ferror(
file_) == 0;
156 throw BagIOException(
"Can't set compression mode before opening a file");
161 stream->startWrite();
168 throw BagIOException(
"Can't set compression mode before opening a file");
200 return ftruncate(fd, length) == 0;
206 if(fgets(buffer, 1024,
file_))
217 stream_factory_->getStream(compression)->decompress(dest, dest_len, source, source_len);
void openRead(std::string const &filename)
open file for reading
std::shared_ptr< StreamFactory > stream_factory_
void setReadMode(CompressionType type)
std::shared_ptr< Stream > read_stream_
void read(void *ptr, size_t size)
read size bytes from the file into ptr
bool good() const
return true if hasn't reached end-of-file and no error
void open(std::string const &filename, std::string const &mode)
void write(std::string const &s)
uint64_t getOffset() const
return current offset from the beginning of the file
bool truncate(uint64_t length)
void seek(uint64_t offset, int origin=std::ios_base::beg)
seek to given offset from origin
GLsizei const GLchar *const * string
void close()
close the file
uint32_t getCompressedBytesIn() const
return the number of bytes written to current compressed stream
uint64_t offset_
current position in the file
void setWriteMode(CompressionType type)
int nUnused_
number of bytes of extra data read by compressed stream
Base class for all exceptions thrown by ROS.
Exception thrown when on IO problems.
GLint GLint GLsizei GLint GLenum format
unsigned __int64 uint64_t
bool isOpen() const
return true if file is open for reading or writing
std::shared_ptr< Stream > write_stream_
uint64_t compressed_in_
number of bytes written to current compressed stream
std::string filename_
path to file
basic_format< char > format
void openWrite(std::string const &filename)
open file for writing
void decompress(CompressionType compression, uint8_t *dest, unsigned int dest_len, uint8_t *source, unsigned int source_len)
GLsizei GLsizei GLchar * source
GLenum GLuint GLenum GLsizei length
std::string getFileName() const
return path of currently open file
void openReadWrite(std::string const &filename)
open file for reading & writing
char * unused_
extra data read by compressed stream