mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-05-17 07:21:43 +00:00
feat: add support for extracting ipaks to ImageConverter
This commit is contained in:
@@ -55,7 +55,7 @@ namespace
|
||||
return true;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::unique_ptr<iobjstream> GetEntryStream(const Hash nameHash, const Hash dataHash) const override
|
||||
[[nodiscard]] std::unique_ptr<iobjstream> GetEntryStream(const IPakHash nameHash, const IPakHash dataHash) const override
|
||||
{
|
||||
const IPakIndexEntryKey wantedKey{
|
||||
{.dataHash = dataHash, .nameHash = nameHash}
|
||||
@@ -77,6 +77,11 @@ namespace
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
[[nodiscard]] const std::vector<IPakIndexEntry>& GetIndexEntries() const override
|
||||
{
|
||||
return m_index_entries;
|
||||
}
|
||||
|
||||
std::string GetName() override
|
||||
{
|
||||
return fs::path(m_path).filename().replace_extension("").string();
|
||||
@@ -203,12 +208,12 @@ std::unique_ptr<IIPak> IIPak::Create(std::string path, std::unique_ptr<std::istr
|
||||
return std::make_unique<IPak>(std::move(path), std::move(stream));
|
||||
}
|
||||
|
||||
IIPak::Hash IIPak::HashString(const std::string& str)
|
||||
IPakHash IIPak::HashString(const std::string& str)
|
||||
{
|
||||
return R_HashString(str.c_str(), 0);
|
||||
}
|
||||
|
||||
IIPak::Hash IIPak::HashData(const void* data, const size_t dataSize)
|
||||
IPakHash IIPak::HashData(const void* data, const size_t dataSize)
|
||||
{
|
||||
return crc32(0, static_cast<const Bytef*>(data), static_cast<unsigned>(dataSize));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "ObjContainer/IPak/IPakTypes.h"
|
||||
#include "ObjContainer/ObjContainerReferenceable.h"
|
||||
#include "ObjContainer/ObjContainerRepository.h"
|
||||
#include "Utils/ObjStream.h"
|
||||
@@ -14,19 +15,20 @@ class IIPak : public ObjContainerReferenceable
|
||||
{
|
||||
public:
|
||||
static ObjContainerRepository<IIPak, Zone> Repository;
|
||||
typedef std::uint32_t Hash;
|
||||
|
||||
IIPak() = default;
|
||||
virtual ~IIPak() = default;
|
||||
~IIPak() override = default;
|
||||
IIPak(const IIPak& other) = default;
|
||||
IIPak(IIPak&& other) noexcept = default;
|
||||
IIPak& operator=(const IIPak& other) = default;
|
||||
IIPak& operator=(IIPak&& other) noexcept = default;
|
||||
|
||||
virtual bool Initialize() = 0;
|
||||
[[nodiscard]] virtual std::unique_ptr<iobjstream> GetEntryStream(Hash nameHash, Hash dataHash) const = 0;
|
||||
[[nodiscard]] virtual std::unique_ptr<iobjstream> GetEntryStream(IPakHash nameHash, IPakHash dataHash) const = 0;
|
||||
|
||||
[[nodiscard]] virtual const std::vector<IPakIndexEntry>& GetIndexEntries() const = 0;
|
||||
|
||||
static std::unique_ptr<IIPak> Create(std::string path, std::unique_ptr<std::istream> stream);
|
||||
static Hash HashString(const std::string& str);
|
||||
static Hash HashData(const void* data, size_t dataSize);
|
||||
static IPakHash HashString(const std::string& str);
|
||||
static IPakHash HashData(const void* data, size_t dataSize);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user