Files
OpenVulkano/openVulkanoCpp/IO/MemMappedFile.hpp
mtuncbilek 95ddd4b23f memmappedfile-fix (#115)
Co-authored-by: Metehan Tuncbilek <mtuncbilek95@gmail.com>
Reviewed-by: Georg Hagen <georg.hagen@madvoxel.com>
Co-authored-by: mtuncbilek <metehan.tuncbilek@madvoxel.com>
Co-committed-by: mtuncbilek <metehan.tuncbilek@madvoxel.com>
2024-09-21 14:46:39 +02:00

40 lines
856 B
C++

/*
* 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 MemMappedFileInternal;
class MemMappedFile
{
friend class MemMappedFileWriteHelper;
std::shared_ptr<MemMappedFileInternal> 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; }
};
}