libkeepass 0.2.0
KeePass key database importer/exporter library
Loading...
Searching...
No Matches
keepass::detail::MappedFile Class Referencefinal

Read-only memory mapping of a file. More...

#include <mapped_file.hh>

Public Member Functions

 MappedFile (const std::string &path)
 Opens and maps the file at path.
 
 ~MappedFile ()
 Unmaps the file and releases all handles.
 
 MappedFile (const MappedFile &)=delete
 
MappedFile & operator= (const MappedFile &)=delete
 
 MappedFile (MappedFile &&)=delete
 
MappedFile & operator= (MappedFile &&)=delete
 
const char * data () const noexcept
 Returns a pointer to the first mapped byte (nullptr for an empty file).
 
std::size_t size () const noexcept
 Returns the size of the mapping in bytes.
 
bool empty () const noexcept
 Returns whether the file is empty.
 

Detailed Description

Read-only memory mapping of a file.

On POSIX systems the file is mapped with mmap; on Windows a read-only file mapping is created with CreateFileMapping/MapViewOfFile. The mapping is released when the object is destroyed. The file must not be truncated while the mapping is alive (the operating system may deliver SIGBUS/raise an exception on access to the missing pages).

Constructor & Destructor Documentation

◆ MappedFile()

keepass::detail::MappedFile::MappedFile ( const std::string &  path)
explicit

Opens and maps the file at path.

Exceptions
FileNotFoundErrorif the path does not exist.
IoErrorif the file cannot be opened or mapped.

The documentation for this class was generated from the following file: