Add ArchiveReader
This commit is contained in:
53
openVulkanoCpp/IO/Archive/ArchiveReader.hpp
Normal file
53
openVulkanoCpp/IO/Archive/ArchiveReader.hpp
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 "ArchiveBase.hpp"
|
||||
#include "Data/Containers/Array.hpp"
|
||||
#include <string_view>
|
||||
#include <optional>
|
||||
#include <functional>
|
||||
#include <ostream>
|
||||
|
||||
namespace openVulkanoCpp
|
||||
{
|
||||
class ArchiveReader final : public ArchiveBase
|
||||
{
|
||||
bool m_eof = false;
|
||||
void ReadNextHeader();
|
||||
|
||||
public:
|
||||
explicit ArchiveReader(const char* archiveFile, const std::shared_ptr<spdlog::logger>& logger = nullptr);
|
||||
|
||||
explicit ArchiveReader(const std::string& archiveFile, const std::shared_ptr<spdlog::logger>& logger = nullptr);
|
||||
|
||||
ArchiveReader(const void* archiveBuffer, size_t size, const std::shared_ptr<spdlog::logger>& logger = nullptr);
|
||||
|
||||
~ArchiveReader() override;
|
||||
|
||||
size_t ExtractRemaining(std::string_view targetDir);
|
||||
|
||||
// Element wise operations
|
||||
[[nodiscard]] bool HasNext() const;
|
||||
|
||||
void SkipNext();
|
||||
|
||||
bool SkipTill(std::filesystem::file_type type = std::filesystem::file_type::regular);
|
||||
|
||||
[[nodiscard]] FileDescription GetNextDescription() const;
|
||||
|
||||
std::optional<FileDescription> GetNextDirectory();
|
||||
|
||||
std::optional<FileDescription> ExtractNext(std::string_view targetDir);
|
||||
|
||||
std::optional<std::pair<FileDescription, Array<char>>> GetNextFile();
|
||||
|
||||
std::optional<FileDescription> StreamNextFile(std::ostream& stream);
|
||||
|
||||
bool GetNextFileAsStream(const std::function<void(const FileDescription&, std::istream&)>& streamReader);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user