Add MemMappedFile

This commit is contained in:
2023-11-02 23:56:32 +01:00
parent 84cc87c1d3
commit 56823ff415
2 changed files with 161 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <filesystem>
namespace OpenVulkano
{
class MemMappedFile
{
class Internal;
std::shared_ptr<Internal> m_internal;
void* m_data;
size_t m_size;
public:
enum FileMode : int { READ_ONLY = 0, WRITE_ONLY, READ_WRITE };
MemMappedFile(const std::filesystem::path& path, FileMode fileMode = READ_ONLY);
[[nodiscard]] bool IsOpen() const { return m_data; }
[[nodiscard]] operator bool() const { return m_data; }
[[nodiscard]] size_t Size() const { return m_size; }
[[nodiscard]] void* Data() const { return m_data; }
};
}