Fix build

Explicitly use `std::min<std::size_t>`

Added virtual destructor
This commit is contained in:
zhupengfei 2020-02-07 16:26:33 +08:00
parent eed9de2336
commit 6e0afbaa19
No known key found for this signature in database
GPG key ID: DD129E108BD09378
3 changed files with 10 additions and 5 deletions

View file

@ -515,11 +515,12 @@ std::size_t LayeredFS::ReadFile(std::size_t offset, std::size_t length, u8* buff
const auto relative_offset = offset - current->first;
std::size_t to_read{};
if (current->second->relocation.size > relative_offset) {
to_read =
std::min(current->second->relocation.size - relative_offset, length - read_size);
to_read = std::min<std::size_t>(current->second->relocation.size - relative_offset,
length - read_size);
}
const auto alignment =
std::min(Common::AlignUp(current->second->relocation.size, 16) - relative_offset,
std::min<std::size_t>(Common::AlignUp(current->second->relocation.size, 16) -
relative_offset,
length - read_size) -
to_read;

View file

@ -42,7 +42,7 @@ class LayeredFS : public RomFSReader {
public:
explicit LayeredFS(std::shared_ptr<RomFSReader> romfs, std::string patch_path,
std::string patch_ext_path);
~LayeredFS();
~LayeredFS() override;
std::size_t GetSize() const override;
std::size_t ReadFile(std::size_t offset, std::size_t length, u8* buffer) override;

View file

@ -11,6 +11,8 @@ namespace FileSys {
*/
class RomFSReader {
public:
virtual ~RomFSReader() = default;
virtual std::size_t GetSize() const = 0;
virtual std::size_t ReadFile(std::size_t offset, std::size_t length, u8* buffer) = 0;
};
@ -30,6 +32,8 @@ public:
: is_encrypted(true), file(std::move(file)), key(key), ctr(ctr), file_offset(file_offset),
crypto_offset(crypto_offset), data_size(data_size) {}
~DirectRomFSReader() override = default;
std::size_t GetSize() const override {
return data_size;
}