From 57616f9758a23bbb9d1f7c5797c2831926004e49 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 25 Sep 2018 17:56:14 -0400 Subject: 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. --- src/core/file_sys/fsmitm_romfsbuild.cpp | 2 +- src/core/file_sys/vfs.cpp | 6 +++--- src/core/file_sys/vfs.h | 9 +++++---- src/core/file_sys/vfs_static.h | 16 ++++++++-------- src/core/file_sys/vfs_vector.cpp | 4 ++-- src/core/file_sys/vfs_vector.h | 8 ++++---- src/yuzu/main.cpp | 14 +++++++------- 7 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/core/file_sys/fsmitm_romfsbuild.cpp b/src/core/file_sys/fsmitm_romfsbuild.cpp index 21fc3d796..16172445a 100644 --- a/src/core/file_sys/fsmitm_romfsbuild.cpp +++ b/src/core/file_sys/fsmitm_romfsbuild.cpp @@ -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); diff --git a/src/core/file_sys/vfs.cpp b/src/core/file_sys/vfs.cpp index 5fbea1739..bfe50da73 100644 --- a/src/core/file_sys/vfs.cpp +++ b/src/core/file_sys/vfs.cpp @@ -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 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; diff --git a/src/core/file_sys/vfs.h b/src/core/file_sys/vfs.h index cea4aa8b8..270291631 100644 --- a/src/core/file_sys/vfs.h +++ b/src/core/file_sys/vfs.h @@ -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. diff --git a/src/core/file_sys/vfs_static.h b/src/core/file_sys/vfs_static.h index 8ad77d300..44fab51d1 100644 --- a/src/core/file_sys/vfs_static.h +++ b/src/core/file_sys/vfs_static.h @@ -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 ReadByte(size_t offset) const override { + boost::optional ReadByte(std::size_t offset) const override { if (offset < size) return value; return boost::none; } - std::vector ReadBytes(size_t length, size_t offset) const override { + std::vector ReadBytes(std::size_t length, std::size_t offset) const override { const auto read = std::min(length, size - offset); return std::vector(read, value); } @@ -71,7 +71,7 @@ public: private: u8 value; - size_t size; + std::size_t size; std::string name; VirtualDir parent; }; diff --git a/src/core/file_sys/vfs_vector.cpp b/src/core/file_sys/vfs_vector.cpp index 7033e2c88..23cff3fb9 100644 --- a/src/core/file_sys/vfs_vector.cpp +++ b/src/core/file_sys/vfs_vector.cpp @@ -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); diff --git a/src/core/file_sys/vfs_vector.h b/src/core/file_sys/vfs_vector.h index 115c3ae95..48a414c98 100644 --- a/src/core/file_sys/vfs_vector.h +++ b/src/core/file_sys/vfs_vector.h @@ -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 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 new_data); diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index dc8b5407d..1455edc89 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -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 calculate_entry_size = + static const std::function 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 + static const std::function 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())) -- cgit v1.2.3