nod/lib/DiscGCN.cpp

58 lines
1.4 KiB
C++
Raw Normal View History

2015-06-28 05:43:53 +00:00
#include "DiscGCN.hpp"
namespace NOD
{
2015-06-30 00:07:46 +00:00
class PartitionGCN : public DiscBase::IPartition
{
public:
PartitionGCN(const DiscGCN& parent, Kind kind, size_t offset)
: IPartition(parent, kind, offset)
{
/* GCN-specific header reads */
2015-06-30 06:46:19 +00:00
std::unique_ptr<IPartReadStream> s = beginReadStream(0x420);
2015-06-30 00:07:46 +00:00
uint32_t vals[3];
s->read(vals, 12);
m_dolOff = SBig(vals[0]);
m_fstOff = SBig(vals[1]);
m_fstSz = SBig(vals[2]);
/* Yay files!! */
parseFST(*s.get());
}
2015-06-30 06:46:19 +00:00
class PartReadStream : public IPartReadStream
2015-06-30 00:07:46 +00:00
{
const PartitionGCN& m_parent;
std::unique_ptr<IDiscIO::IReadStream> m_dio;
public:
PartReadStream(const PartitionGCN& parent, size_t offset)
: m_parent(parent)
{m_dio = m_parent.m_parent.getDiscIO().beginReadStream(offset);}
void seek(size_t offset, int whence)
{m_dio->seek(offset, whence);}
size_t read(void* buf, size_t length)
{return m_dio->read(buf, length);}
};
2015-06-30 06:46:19 +00:00
std::unique_ptr<IPartReadStream> beginReadStream(size_t offset) const
2015-06-30 00:07:46 +00:00
{
2015-06-30 06:46:19 +00:00
return std::unique_ptr<IPartReadStream>(new PartReadStream(*this, offset));
2015-06-30 00:07:46 +00:00
}
};
2015-06-28 05:43:53 +00:00
DiscGCN::DiscGCN(std::unique_ptr<IDiscIO>&& dio)
: DiscBase(std::move(dio))
{
2015-06-30 00:07:46 +00:00
/* One lone partition for GCN */
m_partitions.emplace_back(new PartitionGCN(*this, IPartition::PART_DATA, 0));
2015-06-28 05:43:53 +00:00
}
bool DiscGCN::commit()
{
return false;
}
}