lightningbolt/lib/base/MmapFile.hpp

25 lines
513 B
C++
Raw Normal View History

#pragma once
#include <base/Types.hpp>
#include <base/ErrorOr.hpp>
namespace lightningbolt {
/// A read-only file opened via memory mapping.
/// On POSIX systems, we use mmap(2). Etc etc.
struct MmapFile {
MmapFile();
~MmapFile();
// Opens for read-only mode.
ErrorOr<void> Open(const fs::path& path);
void Close();
u8* GetMapping() const;
usize GetMappingSize() const;
private:
struct Impl;
Unique<Impl> impl;
};
}