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();
|
||||
}
|
||||
const std::vector<u8> CNANDContentDataFile::Get()
|
||||
std::vector<u8> CNANDContentDataFile::Get()
|
||||
{
|
||||
std::vector<u8> result;
|
||||
EnsureOpen();
|
||||
|
||||
if (!m_file->IsGood())
|
||||
return result;
|
||||
return {};
|
||||
|
||||
u64 size = m_file->GetSize();
|
||||
if (size == 0)
|
||||
return result;
|
||||
return {};
|
||||
|
||||
result.resize(size);
|
||||
std::vector<u8> result(size);
|
||||
m_file->ReadBytes(result.data(), result.size());
|
||||
|
||||
return result;
|
||||
|
|
|
@ -26,19 +26,18 @@ class CNANDContentData
|
|||
{
|
||||
public:
|
||||
virtual ~CNANDContentData() = 0;
|
||||
virtual void Open(){};
|
||||
virtual const std::vector<u8> Get() = 0;
|
||||
virtual void Open() {}
|
||||
virtual std::vector<u8> Get() = 0;
|
||||
virtual bool GetRange(u32 start, u32 size, u8* buffer) = 0;
|
||||
virtual void Close(){};
|
||||
virtual void Close() {}
|
||||
};
|
||||
|
||||
class CNANDContentDataFile final : public CNANDContentData
|
||||
{
|
||||
public:
|
||||
CNANDContentDataFile(const std::string& filename) : m_filename(filename){};
|
||||
|
||||
explicit CNANDContentDataFile(const std::string& filename) : m_filename(filename) {}
|
||||
void Open() override;
|
||||
const std::vector<u8> Get() override;
|
||||
std::vector<u8> Get() override;
|
||||
bool GetRange(u32 start, u32 size, u8* buffer) override;
|
||||
void Close() override;
|
||||
|
||||
|
@ -51,9 +50,8 @@ private:
|
|||
class CNANDContentDataBuffer final : public CNANDContentData
|
||||
{
|
||||
public:
|
||||
CNANDContentDataBuffer(const std::vector<u8>& buffer) : m_buffer(buffer){};
|
||||
|
||||
const std::vector<u8> Get() override { return m_buffer; };
|
||||
explicit CNANDContentDataBuffer(const std::vector<u8>& buffer) : m_buffer(buffer) {}
|
||||
std::vector<u8> Get() override { return m_buffer; }
|
||||
bool GetRange(u32 start, u32 size, u8* buffer) override;
|
||||
|
||||
private:
|
||||
|
@ -76,8 +74,8 @@ struct SNANDContent
|
|||
class CNANDContentLoader final
|
||||
{
|
||||
public:
|
||||
CNANDContentLoader(const std::string& content_name);
|
||||
virtual ~CNANDContentLoader();
|
||||
explicit CNANDContentLoader(const std::string& content_name);
|
||||
~CNANDContentLoader();
|
||||
|
||||
bool IsValid() const { return m_Valid; }
|
||||
void RemoveTitle() const;
|
||||
|
|
Loading…
Reference in New Issue