diff --git a/Source/Core/DiscIO/NANDContentLoader.cpp b/Source/Core/DiscIO/NANDContentLoader.cpp index 98978d98b0..3f2c746bd6 100644 --- a/Source/Core/DiscIO/NANDContentLoader.cpp +++ b/Source/Core/DiscIO/NANDContentLoader.cpp @@ -107,18 +107,18 @@ void CNANDContentDataFile::Open() { EnsureOpen(); } -const std::vector CNANDContentDataFile::Get() +std::vector CNANDContentDataFile::Get() { - std::vector 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 result(size); m_file->ReadBytes(result.data(), result.size()); return result; diff --git a/Source/Core/DiscIO/NANDContentLoader.h b/Source/Core/DiscIO/NANDContentLoader.h index 71afc4ce39..6c9df0d545 100644 --- a/Source/Core/DiscIO/NANDContentLoader.h +++ b/Source/Core/DiscIO/NANDContentLoader.h @@ -26,19 +26,18 @@ class CNANDContentData { public: virtual ~CNANDContentData() = 0; - virtual void Open(){}; - virtual const std::vector Get() = 0; + virtual void Open() {} + virtual std::vector 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 Get() override; + std::vector 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& buffer) : m_buffer(buffer){}; - - const std::vector Get() override { return m_buffer; }; + explicit CNANDContentDataBuffer(const std::vector& buffer) : m_buffer(buffer) {} + std::vector 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;