vfs/etc: Append std:: to size_t usages

Given we just recently had a patch backport this from citra, let's try
and keep the convention uniform.
This commit is contained in:
Lioncash 2018-09-25 17:56:14 -04:00
parent 28bef31ea8
commit 57616f9758
7 changed files with 30 additions and 29 deletions

View File

@ -97,7 +97,7 @@ struct RomFSBuildFileContext {
RomFSBuildFileContext() : path(""), cur_path_ofs(0), path_len(0) {}
};
static u32 romfs_calc_path_hash(u32 parent, std::string path, u32 start, size_t path_len) {
static u32 romfs_calc_path_hash(u32 parent, std::string path, u32 start, std::size_t path_len) {
u32 hash = parent ^ 123456789;
for (u32 i = 0; i < path_len; i++) {
hash = (hash >> 5) | (hash << 27);

View File

@ -463,14 +463,14 @@ bool DeepEquals(const VirtualFile& file1, const VirtualFile& file2, std::size_t
return true;
}
bool VfsRawCopy(const VirtualFile& src, const VirtualFile& dest, size_t block_size) {
bool VfsRawCopy(const VirtualFile& src, const VirtualFile& dest, std::size_t block_size) {
if (src == nullptr || dest == nullptr || !src->IsReadable() || !dest->IsWritable())
return false;
if (!dest->Resize(src->GetSize()))
return false;
std::vector<u8> temp(std::min(block_size, src->GetSize()));
for (size_t i = 0; i < src->GetSize(); i += block_size) {
for (std::size_t i = 0; i < src->GetSize(); i += block_size) {
const auto read = std::min(block_size, src->GetSize() - i);
const auto block = src->Read(temp.data(), read, i);
@ -481,7 +481,7 @@ bool VfsRawCopy(const VirtualFile& src, const VirtualFile& dest, size_t block_si
return true;
}
bool VfsRawCopyD(const VirtualDir& src, const VirtualDir& dest, size_t block_size) {
bool VfsRawCopyD(const VirtualDir& src, const VirtualDir& dest, std::size_t block_size) {
if (src == nullptr || dest == nullptr || !src->IsReadable() || !dest->IsWritable())
return false;

View File

@ -315,18 +315,19 @@ public:
bool Rename(std::string_view name) override;
};
// Compare the two files, byte-for-byte, in increments specificed by block_size
bool DeepEquals(const VirtualFile& file1, const VirtualFile& file2, size_t block_size = 0x1000);
// Compare the two files, byte-for-byte, in increments specified by block_size
bool DeepEquals(const VirtualFile& file1, const VirtualFile& file2,
std::size_t block_size = 0x1000);
// A method that copies the raw data between two different implementations of VirtualFile. If you
// are using the same implementation, it is probably better to use the Copy method in the parent
// directory of src/dest.
bool VfsRawCopy(const VirtualFile& src, const VirtualFile& dest, size_t block_size = 0x1000);
bool VfsRawCopy(const VirtualFile& src, const VirtualFile& dest, std::size_t block_size = 0x1000);
// A method that performs a similar function to VfsRawCopy above, but instead copies entire
// directories. It suffers the same performance penalties as above and an implementation-specific
// Copy should always be preferred.
bool VfsRawCopyD(const VirtualDir& src, const VirtualDir& dest, size_t block_size = 0x1000);
bool VfsRawCopyD(const VirtualDir& src, const VirtualDir& dest, std::size_t block_size = 0x1000);
// Checks if the directory at path relative to rel exists. If it does, returns that. If it does not
// it attempts to create it and returns the new dir or nullptr on failure.

View File

@ -14,7 +14,7 @@ namespace FileSys {
class StaticVfsFile : public VfsFile {
public:
explicit StaticVfsFile(u8 value, size_t size = 0, std::string name = "",
explicit StaticVfsFile(u8 value, std::size_t size = 0, std::string name = "",
VirtualDir parent = nullptr)
: value{value}, size{size}, name{std::move(name)}, parent{std::move(parent)} {}
@ -22,11 +22,11 @@ public:
return name;
}
size_t GetSize() const override {
std::size_t GetSize() const override {
return size;
}
bool Resize(size_t new_size) override {
bool Resize(std::size_t new_size) override {
size = new_size;
return true;
}
@ -43,23 +43,23 @@ public:
return true;
}
size_t Read(u8* data, size_t length, size_t offset) const override {
std::size_t Read(u8* data, std::size_t length, std::size_t offset) const override {
const auto read = std::min(length, size - offset);
std::fill(data, data + read, value);
return read;
}
size_t Write(const u8* data, size_t length, size_t offset) override {
std::size_t Write(const u8* data, std::size_t length, std::size_t offset) override {
return 0;
}
boost::optional<u8> ReadByte(size_t offset) const override {
boost::optional<u8> ReadByte(std::size_t offset) const override {
if (offset < size)
return value;
return boost::none;
}
std::vector<u8> ReadBytes(size_t length, size_t offset) const override {
std::vector<u8> ReadBytes(std::size_t length, std::size_t offset) const override {
const auto read = std::min(length, size - offset);
return std::vector<u8>(read, value);
}
@ -71,7 +71,7 @@ public:
private:
u8 value;
size_t size;
std::size_t size;
std::string name;
VirtualDir parent;
};

View File

@ -38,13 +38,13 @@ bool VectorVfsFile::IsReadable() const {
return true;
}
size_t VectorVfsFile::Read(u8* data_, size_t length, size_t offset) const {
std::size_t VectorVfsFile::Read(u8* data_, std::size_t length, std::size_t offset) const {
const auto read = std::min(length, data.size() - offset);
std::memcpy(data_, data.data() + offset, read);
return read;
}
size_t VectorVfsFile::Write(const u8* data_, size_t length, size_t offset) {
std::size_t VectorVfsFile::Write(const u8* data_, std::size_t length, std::size_t offset) {
if (offset + length > data.size())
data.resize(offset + length);
const auto write = std::min(length, data.size() - offset);

View File

@ -16,13 +16,13 @@ public:
~VectorVfsFile() override;
std::string GetName() const override;
size_t GetSize() const override;
bool Resize(size_t new_size) override;
std::size_t GetSize() const override;
bool Resize(std::size_t new_size) override;
std::shared_ptr<VfsDirectory> GetContainingDirectory() const override;
bool IsWritable() const override;
bool IsReadable() const override;
size_t Read(u8* data, size_t length, size_t offset) const override;
size_t Write(const u8* data, size_t length, size_t offset) override;
std::size_t Read(u8* data, std::size_t length, std::size_t offset) const override;
std::size_t Write(const u8* data, std::size_t length, std::size_t offset) override;
bool Rename(std::string_view name) override;
virtual void Assign(std::vector<u8> new_data);

View File

@ -760,7 +760,7 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa
const auto path = fmt::format("{}{:016X}/romfs",
FileUtil::GetUserPath(FileUtil::UserPath::DumpDir), program_id);
auto failed = [this, &path]() {
const auto failed = [this, &path] {
QMessageBox::warning(this, tr("RomFS Extraction Failed!"),
tr("There was an error copying the RomFS files or the user "
"cancelled the operation."));
@ -809,9 +809,9 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa
const auto full = res == "Full";
const static std::function<size_t(const FileSys::VirtualDir&, bool)> calculate_entry_size =
static const std::function<std::size_t(const FileSys::VirtualDir&, bool)> calculate_entry_size =
[](const FileSys::VirtualDir& dir, bool full) {
size_t out = 0;
std::size_t out = 0;
for (const auto& subdir : dir->GetSubdirectories())
out += 1 + calculate_entry_size(subdir, full);
return out + full ? dir->GetFiles().size() : 0;
@ -822,10 +822,10 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa
progress.setWindowModality(Qt::WindowModal);
progress.setMinimumDuration(100);
const static std::function<bool(QProgressDialog&, const FileSys::VirtualDir&,
const FileSys::VirtualDir&, size_t, bool)>
static const std::function<bool(QProgressDialog&, const FileSys::VirtualDir&,
const FileSys::VirtualDir&, std::size_t, bool)>
qt_raw_copy = [](QProgressDialog& dialog, const FileSys::VirtualDir& src,
const FileSys::VirtualDir& dest, size_t block_size, bool full) {
const FileSys::VirtualDir& dest, std::size_t block_size, bool full) {
if (src == nullptr || dest == nullptr || !src->IsReadable() || !dest->IsWritable())
return false;
if (dialog.wasCanceled())
@ -931,7 +931,7 @@ void GMainWindow::OnMenuInstallToNAND() {
}
const auto qt_raw_copy = [this](const FileSys::VirtualFile& src,
const FileSys::VirtualFile& dest, size_t block_size) {
const FileSys::VirtualFile& dest, std::size_t block_size) {
if (src == nullptr || dest == nullptr)
return false;
if (!dest->Resize(src->GetSize()))