/*
 * 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() : m_data(nullptr), m_size(0) {}

		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; }
	};
}