Add MemMappedFile
This commit is contained in:
34
openVulkanoCpp/IO/MemMappedFile.hpp
Normal file
34
openVulkanoCpp/IO/MemMappedFile.hpp
Normal 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; }
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user