Merge pull request #5865 from JosJuice/noncopyable-move

DirectoryBlob: Use NonCopyable
This commit is contained in:
Leo Lam 2017-08-02 11:56:16 +08:00 committed by GitHub
commit c7602cce04
2 changed files with 8 additions and 14 deletions

View File

@ -13,4 +13,7 @@ protected:
NonCopyable(const NonCopyable&) = delete;
NonCopyable& operator=(const NonCopyable&) = delete;
NonCopyable(NonCopyable&&) = default;
NonCopyable& operator=(NonCopyable&&) = default;
};

View File

@ -15,6 +15,7 @@
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/NonCopyable.h"
#include "DiscIO/Blob.h"
namespace File
@ -58,18 +59,13 @@ private:
ContentSource m_content_source;
};
class DirectoryBlobPartition
// We do not allow copying, because it might mess up the pointers inside DiscContents
class DirectoryBlobPartition : private NonCopyable
{
public:
DirectoryBlobPartition() = default;
DirectoryBlobPartition(const std::string& root_directory, std::optional<bool> is_wii);
// We do not allow copying, because it might mess up the pointers inside DiscContents
DirectoryBlobPartition(const DirectoryBlobPartition&) = delete;
DirectoryBlobPartition& operator=(const DirectoryBlobPartition&) = delete;
DirectoryBlobPartition(DirectoryBlobPartition&&) = default;
DirectoryBlobPartition& operator=(DirectoryBlobPartition&&) = default;
bool IsWii() const { return m_is_wii; }
u64 GetDataSize() const { return m_data_size; }
const std::string& GetRootDirectory() const { return m_root_directory; }
@ -107,17 +103,12 @@ private:
u64 m_data_size;
};
class DirectoryBlobReader : public BlobReader
// We do not allow copying, because it might mess up the pointers inside DiscContents
class DirectoryBlobReader : public BlobReader, private NonCopyable
{
public:
static std::unique_ptr<DirectoryBlobReader> Create(const std::string& dol_path);
// We do not allow copying, because it might mess up the pointers inside DiscContents
DirectoryBlobReader(const DirectoryBlobReader&) = delete;
DirectoryBlobReader& operator=(const DirectoryBlobReader&) = delete;
DirectoryBlobReader(DirectoryBlobReader&&) = default;
DirectoryBlobReader& operator=(DirectoryBlobReader&&) = default;
bool Read(u64 offset, u64 length, u8* buffer) override;
bool SupportsReadWiiDecrypted() const override;
bool ReadWiiDecrypted(u64 offset, u64 size, u8* buffer, u64 partition_offset) override;