lightningbolt/lib/base/MmapFile.hpp

29 lines
522 B
C++
Raw Normal View History

// Copyright 2023 The LightningBolt Authors
// SPDX-License-Identifier: MIT
#pragma once
#include <base/Types.hpp>
#include <base/ErrorOr.hpp>
namespace lightningbolt {
2023-11-19 20:24:40 -05:00
/// A read-only file opened via memory mapping.
/// On POSIX systems, we use mmap(2). Etc etc.
struct MmapFile {
MmapFile();
~MmapFile();
2023-11-19 20:24:40 -05:00
// Opens for read-only mode.
ErrorOr<void> Open(const fs::path& path);
void Close();
2023-11-19 20:24:40 -05:00
u8* GetMapping() const;
usize GetMappingSize() const;
2023-11-19 20:24:40 -05:00
private:
struct Impl;
Unique<Impl> impl;
};
2023-11-19 20:24:40 -05:00
}