libopenraw
|
00001 /* 00002 * libopenraw - file.h 00003 * 00004 * Copyright (C) 2006 Hubert Figuière 00005 * 00006 * This library is free software: you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public License 00008 * as published by the Free Software Foundation, either version 3 of 00009 * the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library. If not, see 00018 * <http://www.gnu.org/licenses/>. 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 }