libopenraw
file.cpp
1 /*
2  * libopenraw - file.h
3  *
4  * Copyright (C) 2006 Hubert Figuière
5  *
6  * This library is free software: you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License
8  * as published by the Free Software Foundation, either version 3 of
9  * the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 #include <libopenraw/libopenraw.h>
23 #include "file.h"
24 
25 
26 namespace OpenRaw {
27  namespace IO {
28 
29  File::File(const char *filename)
30  : OpenRaw::IO::Stream(filename),
31  m_methods(::get_default_io_methods()),
32  m_ioRef(NULL)
33  {
34  }
35 
36  File::~File()
37  {
38  }
39 
40  File::Error File::open()
41  {
42  m_ioRef = ::raw_open(m_methods, get_path().c_str(), O_RDONLY);
43  if (m_ioRef == NULL) {
44  return OR_ERROR_CANT_OPEN;
45  }
46  return OR_ERROR_NONE;
47  }
48 
50  {
51  return ::raw_close(m_ioRef);
52  }
53 
54  int File::seek(off_t offset, int whence)
55  {
56  return ::raw_seek(m_ioRef, offset, whence);
57  }
58 
59  int File::read(void *buf, size_t count)
60  {
61  return ::raw_read(m_ioRef, buf, count);
62  }
63 
64  off_t File::filesize()
65  {
66  return ::raw_filesize(m_ioRef);
67  }
68 
69  }
70 }
CIFF is the container for CRW files. It is an attempt from Canon to make this a standard. I guess it failed.
Definition: arwfile.cpp:33
virtual int read(void *buf, size_t count)
Definition: file.cpp:59
const std::string & get_path() const
Definition: stream.h:73
virtual Error open()
Definition: file.cpp:40
virtual int seek(off_t offset, int whence)
Definition: file.cpp:54
virtual int close()
Definition: file.cpp:49
File(const char *filename)
Definition: file.cpp:29
base virtual class for IO
Definition: stream.h:40