25 #include <libopenraw/debug.h>
28 #include "endianutils.hpp"
29 #include "rawcontainer.hpp"
31 using namespace Debug;
43 m_file->seek(_offset, SEEK_SET);
52 bool RawContainer::skip(off_t offset_)
54 m_file->seek(offset_, SEEK_CUR);
62 int s = f->read(&buf, 1);
73 int s = f->read(&buf, 1);
85 LOGERR(
"null endian\n");
90 int s = f->read(buf, 2);
109 LOGERR(
"null endian\n");
113 if (v.size() < count) {
118 for (
size_t i = 0; i < count; i++) {
119 int s = f->read(buf, 2);
141 LOGERR(
"null endian\n");
144 unsigned char buf[4];
145 int s = f->read(buf, 4);
147 LOGERR(
"read %d bytes\n", s);
164 LOGERR(
"null endian\n");
168 unsigned char buf[2];
169 int s = f->read(buf, 2);
185 LOGERR(
"null endian\n");
189 unsigned char buf[4];
190 int s = f->read(buf, 4);
204 size_t buf_size)
const
207 m_file->seek(_offset, SEEK_SET);
208 s =
m_file->read(buf, buf_size);
215 return m_file->filesize();
std::shared_ptr< Stream > Ptr
Option< uint32_t > readUInt32(const IO::Stream::Ptr &f, EndianType endian) const
Read an uint32 following the m_endian set.
Option< uint16_t > readUInt16(const IO::Stream::Ptr &f, EndianType endian) const
Read an uint16 following the m_endian set.
IO::Stream::Ptr m_file
The file handle.
EndianType
Define the endian of the container.
size_t fetchData(void *buf, off_t offset, size_t buf_size) const
Fetch the data chunk from the file.
Option< int32_t > readInt32(const IO::Stream::Ptr &f, EndianType endian) const
Read an int32 following the m_endian set.
Option< int16_t > readInt16(const IO::Stream::Ptr &f, EndianType endian) const
Read an int16 following the m_endian set.
off_t size() const
Return the effective size of the container.
size_t readUInt16Array(const IO::Stream::Ptr &f, std::vector< uint16_t > &v, size_t count) const
Read an array of uint16 following the m_endian set.
An option type inspired by Rust.
Global namespace for libopenraw.