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)
64 if (m_current == NULL) {
71 m_current = (
unsigned char*)m_ptr + offset;
75 m_current = (
unsigned char*)m_ptr + m_size + offset;
76 newpos = m_size + offset;
80 newpos = (m_current - (
unsigned char*)m_ptr);
90 int MemStream::read(
void *buf,
size_t count)
92 if((m_current == NULL) || (m_ptr == NULL)) {
93 Trace(DEBUG1) <<
"MemStream::failed\n";
97 unsigned char * end = (
unsigned char*)m_ptr + m_size;
98 if((off_t)count > (end - m_current)) {
99 count = end - m_current;
102 memcpy(buf, m_current, count);
108 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.