lightningbolt/lib/base/MmapFile.hpp

29 lines
522 B
C++

// Copyright 2023 The LightningBolt Authors
// SPDX-License-Identifier: MIT
#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;
};
}