file.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <libopenraw/libopenraw.h>
00023 #include "file.h"
00024
00025
00026 namespace OpenRaw {
00027 namespace IO {
00028
00029 File::File(const char *filename)
00030 : OpenRaw::IO::Stream(filename),
00031 m_methods(::get_default_io_methods()),
00032 m_ioRef(NULL)
00033 {
00034 }
00035
00036 File::~File()
00037 {
00038 }
00039
00040 File::Error File::open()
00041 {
00042 m_ioRef = ::raw_open(m_methods, get_path().c_str(), O_RDONLY);
00043 if (m_ioRef == NULL) {
00044 return OR_ERROR_CANT_OPEN;
00045 }
00046 return OR_ERROR_NONE;
00047 }
00048
00049 int File::close()
00050 {
00051 return ::raw_close(m_ioRef);
00052 }
00053
00054 int File::seek(off_t offset, int whence)
00055 {
00056 return ::raw_seek(m_ioRef, offset, whence);
00057 }
00058
00059 int File::read(void *buf, size_t count)
00060 {
00061 return ::raw_read(m_ioRef, buf, count);
00062 }
00063
00064 off_t File::filesize()
00065 {
00066 return ::raw_filesize(m_ioRef);
00067 }
00068
00069 }
00070 }