mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
DiscIO: Unify CBlobBigEndianReader
This commit is contained in:
parent
c7e747d775
commit
c01265db34
@ -17,6 +17,7 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "Common/CommonFuncs.h"
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
|
||||||
namespace DiscIO
|
namespace DiscIO
|
||||||
@ -77,6 +78,36 @@ private:
|
|||||||
std::array<u64, CACHE_SIZE> m_cache_tags;
|
std::array<u64, CACHE_SIZE> m_cache_tags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CBlobBigEndianReader
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CBlobBigEndianReader(IBlobReader& reader) : m_reader(reader) {}
|
||||||
|
|
||||||
|
u32 Read32(u64 offset) const
|
||||||
|
{
|
||||||
|
u32 temp;
|
||||||
|
m_reader.Read(offset, sizeof(u32), reinterpret_cast<u8*>(&temp));
|
||||||
|
return Common::swap32(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 Read16(u64 offset) const
|
||||||
|
{
|
||||||
|
u16 temp;
|
||||||
|
m_reader.Read(offset, sizeof(u16), reinterpret_cast<u8*>(&temp));
|
||||||
|
return Common::swap16(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 Read8(u64 offset) const
|
||||||
|
{
|
||||||
|
u8 temp;
|
||||||
|
m_reader.Read(offset, sizeof(u8), &temp);
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
IBlobReader& m_reader;
|
||||||
|
};
|
||||||
|
|
||||||
// Factory function - examines the path to choose the right type of IBlobReader, and returns one.
|
// Factory function - examines the path to choose the right type of IBlobReader, and returns one.
|
||||||
std::unique_ptr<IBlobReader> CreateBlobReader(const std::string& filename);
|
std::unique_ptr<IBlobReader> CreateBlobReader(const std::string& filename);
|
||||||
|
|
||||||
|
@ -34,33 +34,6 @@ enum EDiscType
|
|||||||
DISC_TYPE_WAD
|
DISC_TYPE_WAD
|
||||||
};
|
};
|
||||||
|
|
||||||
class CBlobBigEndianReader
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CBlobBigEndianReader(IBlobReader& _rReader) : m_rReader(_rReader) {}
|
|
||||||
|
|
||||||
u32 Read32(u64 _Offset)
|
|
||||||
{
|
|
||||||
u32 Temp;
|
|
||||||
m_rReader.Read(_Offset, 4, (u8*)&Temp);
|
|
||||||
return Common::swap32(Temp);
|
|
||||||
}
|
|
||||||
u16 Read16(u64 _Offset)
|
|
||||||
{
|
|
||||||
u16 Temp;
|
|
||||||
m_rReader.Read(_Offset, 2, (u8*)&Temp);
|
|
||||||
return Common::swap16(Temp);
|
|
||||||
}
|
|
||||||
u8 Read8(u64 _Offset)
|
|
||||||
{
|
|
||||||
u8 Temp;
|
|
||||||
m_rReader.Read(_Offset, 1, &Temp);
|
|
||||||
return Temp;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
IBlobReader& m_rReader;
|
|
||||||
};
|
|
||||||
|
|
||||||
static const unsigned char s_master_key[16] = {
|
static const unsigned char s_master_key[16] = {
|
||||||
0xeb,0xe4,0x2a,0x22,0x5e,0x85,0x93,0xe4,
|
0xeb,0xe4,0x2a,0x22,0x5e,0x85,0x93,0xe4,
|
||||||
0x48,0xd9,0xc5,0x45,0x73,0x81,0xaa,0xf7
|
0x48,0xd9,0xc5,0x45,0x73,0x81,0xaa,0xf7
|
||||||
|
@ -18,22 +18,6 @@
|
|||||||
namespace DiscIO
|
namespace DiscIO
|
||||||
{
|
{
|
||||||
|
|
||||||
class CBlobBigEndianReader
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CBlobBigEndianReader(DiscIO::IBlobReader& _rReader) : m_rReader(_rReader) {}
|
|
||||||
|
|
||||||
u32 Read32(u64 _Offset)
|
|
||||||
{
|
|
||||||
u32 Temp;
|
|
||||||
m_rReader.Read(_Offset, 4, (u8*)&Temp);
|
|
||||||
return(Common::swap32(Temp));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
DiscIO::IBlobReader& m_rReader;
|
|
||||||
};
|
|
||||||
|
|
||||||
WiiWAD::WiiWAD(const std::string& name)
|
WiiWAD::WiiWAD(const std::string& name)
|
||||||
{
|
{
|
||||||
std::unique_ptr<IBlobReader> reader(DiscIO::CreateBlobReader(name));
|
std::unique_ptr<IBlobReader> reader(DiscIO::CreateBlobReader(name));
|
||||||
|
Loading…
Reference in New Issue
Block a user