mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-05-17 07:21:43 +00:00
chore: enable reading of big endian ipaks
This commit is contained in:
@@ -2,14 +2,17 @@
|
||||
|
||||
#include "IPakStreamManager.h"
|
||||
#include "ObjContainer/IPak/IPakTypes.h"
|
||||
#include "Utils/Endianness.h"
|
||||
#include "Utils/ObjStream.h"
|
||||
|
||||
#include <concepts>
|
||||
#include <istream>
|
||||
|
||||
class IPakEntryReadStream final : public objbuf
|
||||
{
|
||||
public:
|
||||
IPakEntryReadStream(std::istream& stream, IPakStreamManagerActions* streamManagerActions, uint8_t* chunkBuffer, int64_t startOffset, size_t entrySize);
|
||||
IPakEntryReadStream(
|
||||
std::istream& stream, bool isLittleEndian, IPakStreamManagerActions* streamManagerActions, uint8_t* chunkBuffer, int64_t startOffset, size_t entrySize);
|
||||
~IPakEntryReadStream() override;
|
||||
|
||||
[[nodiscard]] bool is_open() const override;
|
||||
@@ -34,6 +37,14 @@ private:
|
||||
return num / alignTo * alignTo;
|
||||
}
|
||||
|
||||
template<std::integral T> void SwapBytesIfNecessary(T& value)
|
||||
{
|
||||
if (m_little_endian)
|
||||
value = endianness::FromLittleEndian(value);
|
||||
else
|
||||
value = endianness::FromBigEndian(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Reads the specified chunks from disk.
|
||||
* \param buffer The location to write the loaded data to. Must be able to hold the specified amount of data.
|
||||
@@ -90,6 +101,8 @@ private:
|
||||
|
||||
uint8_t* m_chunk_buffer;
|
||||
|
||||
bool m_little_endian;
|
||||
|
||||
std::istream& m_stream;
|
||||
IPakStreamManagerActions* m_stream_manager_actions;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user