7 #ifndef __LIBCAMERA_INTERNAL_FILE_H__ 8 #define __LIBCAMERA_INTERNAL_FILE_H__ 12 #include <sys/types.h> 14 #include <libcamera/span.h> 33 File(
const std::string &name);
38 File &operator=(
const File &) =
delete;
40 const std::string &
fileName()
const {
return name_; }
45 bool isOpen()
const {
return fd_ != -1; }
49 int error()
const {
return error_; }
52 Span<uint8_t>
map(off_t offset = 0, ssize_t size = -1,
54 bool unmap(uint8_t *addr);
56 static bool exists(
const std::string &name);
66 std::map<void *, size_t> maps_;
OpenMode
Mode in which a file is opened.
Definition: file.h:26
The file is not open.
Definition: file.h:27
MapFlag
Flags for the File::map() function.
Definition: file.h:21
The file is open for writing.
Definition: file.h:29
The file is open for reading.
Definition: file.h:28
bool unmap(uint8_t *addr)
Unmap a region mapped with map()
Definition: file.cpp:309
Definition: bound_method.h:15
File()
Construct a File without an associated name.
Definition: file.cpp:86
void close()
Close the file.
Definition: file.cpp:197
Interface for I/O operations on files.
Definition: file.h:18
const std::string & fileName() const
Retrieve the file name.
Definition: file.h:40
OpenMode openMode() const
Retrieve the file open mode.
Definition: file.h:46
No option (used as default value)
Definition: file.h:22
The file is open for reading and writing.
Definition: file.h:30
bool isOpen() const
Check if the file is open.
Definition: file.h:45
Span< uint8_t > map(off_t offset=0, ssize_t size=-1, MapFlag flags=MapNoOption)
Map a region of the file in the process memory.
Definition: file.cpp:262
void setFileName(const std::string &name)
Set the name of the file.
Definition: file.cpp:118
~File()
Destroy a File instance.
Definition: file.cpp:97
ssize_t size() const
Retrieve the file size.
Definition: file.cpp:227
bool open(OpenMode mode)
Open the file in the given mode.
Definition: file.cpp:158
The memory region is mapped as private, changes are not reflected in the file constents.
Definition: file.h:23
int error() const
Retrieve the file error status.
Definition: file.h:49
bool exists() const
Check if the file specified by fileName() exists.
Definition: file.cpp:141