Merge pull request #4214 from lioncash/nandcontent
NANDContentLoader: Minor changes
This commit is contained in:
commit
331b112816
|
@ -107,18 +107,18 @@ void CNANDContentDataFile::Open()
|
||||||
{
|
{
|
||||||
EnsureOpen();
|
EnsureOpen();
|
||||||
}
|
}
|
||||||
const std::vector<u8> CNANDContentDataFile::Get()
|
std::vector<u8> CNANDContentDataFile::Get()
|
||||||
{
|
{
|
||||||
std::vector<u8> result;
|
|
||||||
EnsureOpen();
|
EnsureOpen();
|
||||||
|
|
||||||
if (!m_file->IsGood())
|
if (!m_file->IsGood())
|
||||||
return result;
|
return {};
|
||||||
|
|
||||||
u64 size = m_file->GetSize();
|
u64 size = m_file->GetSize();
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return result;
|
return {};
|
||||||
|
|
||||||
result.resize(size);
|
std::vector<u8> result(size);
|
||||||
m_file->ReadBytes(result.data(), result.size());
|
m_file->ReadBytes(result.data(), result.size());
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -26,19 +26,18 @@ class CNANDContentData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~CNANDContentData() = 0;
|
virtual ~CNANDContentData() = 0;
|
||||||
virtual void Open(){};
|
virtual void Open() {}
|
||||||
virtual const std::vector<u8> Get() = 0;
|
virtual std::vector<u8> Get() = 0;
|
||||||
virtual bool GetRange(u32 start, u32 size, u8* buffer) = 0;
|
virtual bool GetRange(u32 start, u32 size, u8* buffer) = 0;
|
||||||
virtual void Close(){};
|
virtual void Close() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class CNANDContentDataFile final : public CNANDContentData
|
class CNANDContentDataFile final : public CNANDContentData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CNANDContentDataFile(const std::string& filename) : m_filename(filename){};
|
explicit CNANDContentDataFile(const std::string& filename) : m_filename(filename) {}
|
||||||
|
|
||||||
void Open() override;
|
void Open() override;
|
||||||
const std::vector<u8> Get() override;
|
std::vector<u8> Get() override;
|
||||||
bool GetRange(u32 start, u32 size, u8* buffer) override;
|
bool GetRange(u32 start, u32 size, u8* buffer) override;
|
||||||
void Close() override;
|
void Close() override;
|
||||||
|
|
||||||
|
@ -51,9 +50,8 @@ private:
|
||||||
class CNANDContentDataBuffer final : public CNANDContentData
|
class CNANDContentDataBuffer final : public CNANDContentData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CNANDContentDataBuffer(const std::vector<u8>& buffer) : m_buffer(buffer){};
|
explicit CNANDContentDataBuffer(const std::vector<u8>& buffer) : m_buffer(buffer) {}
|
||||||
|
std::vector<u8> Get() override { return m_buffer; }
|
||||||
const std::vector<u8> Get() override { return m_buffer; };
|
|
||||||
bool GetRange(u32 start, u32 size, u8* buffer) override;
|
bool GetRange(u32 start, u32 size, u8* buffer) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -76,8 +74,8 @@ struct SNANDContent
|
||||||
class CNANDContentLoader final
|
class CNANDContentLoader final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CNANDContentLoader(const std::string& content_name);
|
explicit CNANDContentLoader(const std::string& content_name);
|
||||||
virtual ~CNANDContentLoader();
|
~CNANDContentLoader();
|
||||||
|
|
||||||
bool IsValid() const { return m_Valid; }
|
bool IsValid() const { return m_Valid; }
|
||||||
void RemoveTitle() const;
|
void RemoveTitle() const;
|
||||||
|
|
Loading…
Reference in New Issue