Pixie
Loading...
Searching...
No Matches
pixie::io::MappedFile Class Reference

Move-only owner of a read-only POSIX memory-mapped file. More...

#include <mapped_file.h>

Public Member Functions

 MappedFile (const std::filesystem::path &path)
 Map path for reading.
 
 MappedFile (const MappedFile &)=delete
 
MappedFileoperator= (const MappedFile &)=delete
 
 MappedFile (MappedFile &&other) noexcept
 Transfer ownership of a mapping.
 
MappedFileoperator= (MappedFile &&other) noexcept
 Release this mapping and transfer ownership from other.
 
 ~MappedFile ()
 Unmap the file contents, if any.
 
std::span< const std::byte > as_bytes () const noexcept
 Return the mapped file contents.
 
std::size_t size_bytes () const noexcept
 Return the mapped file size in bytes.
 

Detailed Description

Move-only owner of a read-only POSIX memory-mapped file.

The mapping remains valid after the file is unlinked. Empty files expose an empty byte view without creating a zero-length mapping.

Constructor & Destructor Documentation

◆ MappedFile()

pixie::io::MappedFile::MappedFile ( const std::filesystem::path & path)
inlineexplicit

Map path for reading.

Exceptions
std::system_errorif the file cannot be opened, inspected, or mapped.
std::length_errorif the file does not fit in std::size_t.

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