25 #include <libopenraw/consts.h> 26 #include <libopenraw/debug.h> 28 #include "memstream.hpp" 31 using namespace Debug;
36 MemStream::MemStream(
void *ptr,
size_t s)
44 or_error MemStream::open()
46 m_current = (
unsigned char *)m_ptr;
51 int MemStream::close()
57 int MemStream::seek(off_t offset,
int whence)
62 if (m_current ==
nullptr) {
69 m_current = (
unsigned char*)m_ptr + offset;
73 m_current = (
unsigned char*)m_ptr + m_size + offset;
74 newpos = m_size + offset;
78 newpos = (m_current - (
unsigned char*)m_ptr);
88 int MemStream::read(
void *buf,
size_t count)
90 if((m_current ==
nullptr) || (m_ptr ==
nullptr)) {
91 LOGDBG1(
"MemStream::failed\n");
95 unsigned char * end = (
unsigned char*)m_ptr + m_size;
96 if((off_t)count > (end - m_current)) {
97 count = end - m_current;
100 memcpy(buf, m_current, count);
106 off_t MemStream::filesize()
CIFF is the container for CRW files. It is an attempt from Canon to make this a standard. I guess it failed.