libopenraw  0.3.7
file.hpp
1 /* -*- Mode: C++ -*- */
2 /*
3  * libopenraw - file.hpp
4  *
5  * Copyright (C) 2006-2020 Hubert Figuière
6  *
7  * This library is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation, either version 3 of
10  * the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library. If not, see
19  * <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef OR_INTERNALS_IO_FILE_H_
23 #define OR_INTERNALS_IO_FILE_H_
24 
25 #include <stddef.h>
26 #include <sys/types.h>
27 
28 #include <libopenraw/io.h>
29 
30 #include "stream.hpp"
31 
32 namespace OpenRaw {
33 namespace IO {
34 
39 class File : public Stream {
40 public:
44  File(const char *filename);
45  virtual ~File();
46 
47  File(const File &f) = delete;
48  File &operator=(const File &) = delete;
49 
50  // file APIs
56  virtual Error open() override;
58  virtual int close() override;
60  virtual int seek(off_t offset, int whence) override;
62  virtual int read(void *buf, size_t count) override;
63  virtual off_t filesize() override;
64  //virtual void *mmap(size_t l, off_t offset) override;
65  //virtual int munmap(void *addr, size_t l) override;
66 
67 private:
69  ::io_methods *m_methods;
71  ::IOFileRef m_ioRef;
72 };
73 
75 }
76 }
77 
78 #endif
File IO stream.
Definition: file.hpp:39
virtual int read(void *buf, size_t count) override
read in the file. Semantics are similar to POSIX read()
Definition: file.cpp:74
virtual Error open() override
Open the file.
Definition: file.cpp:49
File(const char *filename)
Definition: file.cpp:35
virtual int close() override
close the file
Definition: file.cpp:62
virtual int seek(off_t offset, int whence) override
seek in the file. Semantics are similar to POSIX lseek()
Definition: file.cpp:69
virtual off_t filesize() override
Return the filesize.
Definition: file.cpp:79
base virtual class for IO
Definition: stream.hpp:44
or_error
Error codes returned by libopenraw.
Definition: consts.h:42
Global namespace for libopenraw.
Definition: arwfile.cpp:29
IO methods for the IO subsystem.
Definition: io.h:51