Expand archive reader

This commit is contained in:
Georg Hagen
2025-02-09 02:13:09 +01:00
parent afd2c8043e
commit ba475e6696
2 changed files with 47 additions and 22 deletions

View File

@@ -12,7 +12,6 @@
#include <string_view>
#include <optional>
#include <functional>
#include <ostream>
#include <queue>
namespace OpenVulkano
@@ -22,6 +21,7 @@ namespace OpenVulkano
std::optional<ArchiveType::Type> m_archiveType;
std::queue<std::string> m_archivesToRead;
std::function<const char*()> m_passwordCallback;
std::function<std::string(std::string)> m_filePathRewrite;
bool m_open = false;
bool m_eof = false;
@@ -38,6 +38,8 @@ namespace OpenVulkano
void SetPasswordCallback(const decltype(m_passwordCallback)& callback);
bool Open(const std::filesystem::path& archiveFile);
bool Open(const char* archiveFile);
bool Open(const std::string& archiveFile);
@@ -50,7 +52,9 @@ namespace OpenVulkano
[[nodiscard]] bool IsOpen() const { return m_open; }
size_t ExtractRemaining(std::string_view targetDir);
[[deprecated]] size_t ExtractRemaining(std::string_view targetDir);
size_t ExtractRemaining(const std::filesystem::path& targetDir);
// Element wise operations
[[nodiscard]] bool HasNext() const;
@@ -63,7 +67,9 @@ namespace OpenVulkano
std::optional<FileDescription> GetNextDirectory();
std::optional<FileDescription> ExtractNext(std::string_view targetDir);
[[deprecated]] std::optional<FileDescription> ExtractNext(std::string_view targetDir) { return ExtractNext(std::filesystem::path(targetDir)); }
std::optional<FileDescription> ExtractNext(const std::filesystem::path& targetDir);
std::optional<std::pair<FileDescription, Array<char>>> GetNextFile();
@@ -76,6 +82,10 @@ namespace OpenVulkano
bool GetNextFileAsStream(const std::function<void(const FileDescription&, std::istream&)>& streamReader);
const decltype(m_passwordCallback)& GetPasswordCallback() const { return m_passwordCallback; }
void SetPathRewriteFunction(const decltype(m_filePathRewrite)& rewriteFunc) { m_filePathRewrite = rewriteFunc; }
const decltype(m_filePathRewrite)& GetPathRewriteFunction() const { return m_filePathRewrite; }
private:
void ReadNextHeader();