diff options
| author | 2018-09-25 17:56:14 -0400 | |
|---|---|---|
| committer | 2018-09-25 20:06:21 -0400 | |
| commit | 57616f9758a23bbb9d1f7c5797c2831926004e49 (patch) | |
| tree | d44d7b33e0b1b0fa1c3dd8c049605c5ed3ef2222 /src | |
| parent | vfs_concat/vfs_layered: Remove friend declarations from ConcatenatedVfsFile (diff) | |
| download | yuzu-57616f9758a23bbb9d1f7c5797c2831926004e49.tar.gz yuzu-57616f9758a23bbb9d1f7c5797c2831926004e49.tar.xz yuzu-57616f9758a23bbb9d1f7c5797c2831926004e49.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/file_sys/fsmitm_romfsbuild.cpp | 2 | ||||
| -rw-r--r-- | src/core/file_sys/vfs.cpp | 6 | ||||
| -rw-r--r-- | src/core/file_sys/vfs.h | 9 | ||||
| -rw-r--r-- | src/core/file_sys/vfs_static.h | 16 | ||||
| -rw-r--r-- | src/core/file_sys/vfs_vector.cpp | 4 | ||||
| -rw-r--r-- | src/core/file_sys/vfs_vector.h | 8 | ||||
| -rw-r--r-- | 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 { | |||
| 97 | RomFSBuildFileContext() : path(""), cur_path_ofs(0), path_len(0) {} | 97 | RomFSBuildFileContext() : path(""), cur_path_ofs(0), path_len(0) {} |
| 98 | }; | 98 | }; |
| 99 | 99 | ||
| 100 | static u32 romfs_calc_path_hash(u32 parent, std::string path, u32 start, size_t path_len) { | 100 | static u32 romfs_calc_path_hash(u32 parent, std::string path, u32 start, std::size_t path_len) { |
| 101 | u32 hash = parent ^ 123456789; | 101 | u32 hash = parent ^ 123456789; |
| 102 | for (u32 i = 0; i < path_len; i++) { | 102 | for (u32 i = 0; i < path_len; i++) { |
| 103 | hash = (hash >> 5) | (hash << 27); | 103 | 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 | |||
| 463 | return true; | 463 | return true; |
| 464 | } | 464 | } |
| 465 | 465 | ||
| 466 | bool VfsRawCopy(const VirtualFile& src, const VirtualFile& dest, size_t block_size) { | 466 | bool VfsRawCopy(const VirtualFile& src, const VirtualFile& dest, std::size_t block_size) { |
| 467 | if (src == nullptr || dest == nullptr || !src->IsReadable() || !dest->IsWritable()) | 467 | if (src == nullptr || dest == nullptr || !src->IsReadable() || !dest->IsWritable()) |
| 468 | return false; | 468 | return false; |
| 469 | if (!dest->Resize(src->GetSize())) | 469 | if (!dest->Resize(src->GetSize())) |
| 470 | return false; | 470 | return false; |
| 471 | 471 | ||
| 472 | std::vector<u8> temp(std::min(block_size, src->GetSize())); | 472 | std::vector<u8> temp(std::min(block_size, src->GetSize())); |
| 473 | for (size_t i = 0; i < src->GetSize(); i += block_size) { | 473 | for (std::size_t i = 0; i < src->GetSize(); i += block_size) { |
| 474 | const auto read = std::min(block_size, src->GetSize() - i); | 474 | const auto read = std::min(block_size, src->GetSize() - i); |
| 475 | const auto block = src->Read(temp.data(), read, i); | 475 | const auto block = src->Read(temp.data(), read, i); |
| 476 | 476 | ||
| @@ -481,7 +481,7 @@ bool VfsRawCopy(const VirtualFile& src, const VirtualFile& dest, size_t block_si | |||
| 481 | return true; | 481 | return true; |
| 482 | } | 482 | } |
| 483 | 483 | ||
| 484 | bool VfsRawCopyD(const VirtualDir& src, const VirtualDir& dest, size_t block_size) { | 484 | bool VfsRawCopyD(const VirtualDir& src, const VirtualDir& dest, std::size_t block_size) { |
| 485 | if (src == nullptr || dest == nullptr || !src->IsReadable() || !dest->IsWritable()) | 485 | if (src == nullptr || dest == nullptr || !src->IsReadable() || !dest->IsWritable()) |
| 486 | return false; | 486 | return false; |
| 487 | 487 | ||
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: | |||
| 315 | bool Rename(std::string_view name) override; | 315 | bool Rename(std::string_view name) override; |
| 316 | }; | 316 | }; |
| 317 | 317 | ||
| 318 | // Compare the two files, byte-for-byte, in increments specificed by block_size | 318 | // Compare the two files, byte-for-byte, in increments specified by block_size |
| 319 | bool DeepEquals(const VirtualFile& file1, const VirtualFile& file2, size_t block_size = 0x1000); | 319 | bool DeepEquals(const VirtualFile& file1, const VirtualFile& file2, |
| 320 | std::size_t block_size = 0x1000); | ||
| 320 | 321 | ||
| 321 | // A method that copies the raw data between two different implementations of VirtualFile. If you | 322 | // A method that copies the raw data between two different implementations of VirtualFile. If you |
| 322 | // are using the same implementation, it is probably better to use the Copy method in the parent | 323 | // are using the same implementation, it is probably better to use the Copy method in the parent |
| 323 | // directory of src/dest. | 324 | // directory of src/dest. |
| 324 | bool VfsRawCopy(const VirtualFile& src, const VirtualFile& dest, size_t block_size = 0x1000); | 325 | bool VfsRawCopy(const VirtualFile& src, const VirtualFile& dest, std::size_t block_size = 0x1000); |
| 325 | 326 | ||
| 326 | // A method that performs a similar function to VfsRawCopy above, but instead copies entire | 327 | // A method that performs a similar function to VfsRawCopy above, but instead copies entire |
| 327 | // directories. It suffers the same performance penalties as above and an implementation-specific | 328 | // directories. It suffers the same performance penalties as above and an implementation-specific |
| 328 | // Copy should always be preferred. | 329 | // Copy should always be preferred. |
| 329 | bool VfsRawCopyD(const VirtualDir& src, const VirtualDir& dest, size_t block_size = 0x1000); | 330 | bool VfsRawCopyD(const VirtualDir& src, const VirtualDir& dest, std::size_t block_size = 0x1000); |
| 330 | 331 | ||
| 331 | // Checks if the directory at path relative to rel exists. If it does, returns that. If it does not | 332 | // Checks if the directory at path relative to rel exists. If it does, returns that. If it does not |
| 332 | // it attempts to create it and returns the new dir or nullptr on failure. | 333 | // 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 { | |||
| 14 | 14 | ||
| 15 | class StaticVfsFile : public VfsFile { | 15 | class StaticVfsFile : public VfsFile { |
| 16 | public: | 16 | public: |
| 17 | explicit StaticVfsFile(u8 value, size_t size = 0, std::string name = "", | 17 | explicit StaticVfsFile(u8 value, std::size_t size = 0, std::string name = "", |
| 18 | VirtualDir parent = nullptr) | 18 | VirtualDir parent = nullptr) |
| 19 | : value{value}, size{size}, name{std::move(name)}, parent{std::move(parent)} {} | 19 | : value{value}, size{size}, name{std::move(name)}, parent{std::move(parent)} {} |
| 20 | 20 | ||
| @@ -22,11 +22,11 @@ public: | |||
| 22 | return name; | 22 | return name; |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | size_t GetSize() const override { | 25 | std::size_t GetSize() const override { |
| 26 | return size; | 26 | return size; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | bool Resize(size_t new_size) override { | 29 | bool Resize(std::size_t new_size) override { |
| 30 | size = new_size; | 30 | size = new_size; |
| 31 | return true; | 31 | return true; |
| 32 | } | 32 | } |
| @@ -43,23 +43,23 @@ public: | |||
| 43 | return true; | 43 | return true; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | size_t Read(u8* data, size_t length, size_t offset) const override { | 46 | std::size_t Read(u8* data, std::size_t length, std::size_t offset) const override { |
| 47 | const auto read = std::min(length, size - offset); | 47 | const auto read = std::min(length, size - offset); |
| 48 | std::fill(data, data + read, value); | 48 | std::fill(data, data + read, value); |
| 49 | return read; | 49 | return read; |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | size_t Write(const u8* data, size_t length, size_t offset) override { | 52 | std::size_t Write(const u8* data, std::size_t length, std::size_t offset) override { |
| 53 | return 0; | 53 | return 0; |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | boost::optional<u8> ReadByte(size_t offset) const override { | 56 | boost::optional<u8> ReadByte(std::size_t offset) const override { |
| 57 | if (offset < size) | 57 | if (offset < size) |
| 58 | return value; | 58 | return value; |
| 59 | return boost::none; | 59 | return boost::none; |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | std::vector<u8> ReadBytes(size_t length, size_t offset) const override { | 62 | std::vector<u8> ReadBytes(std::size_t length, std::size_t offset) const override { |
| 63 | const auto read = std::min(length, size - offset); | 63 | const auto read = std::min(length, size - offset); |
| 64 | return std::vector<u8>(read, value); | 64 | return std::vector<u8>(read, value); |
| 65 | } | 65 | } |
| @@ -71,7 +71,7 @@ public: | |||
| 71 | 71 | ||
| 72 | private: | 72 | private: |
| 73 | u8 value; | 73 | u8 value; |
| 74 | size_t size; | 74 | std::size_t size; |
| 75 | std::string name; | 75 | std::string name; |
| 76 | VirtualDir parent; | 76 | VirtualDir parent; |
| 77 | }; | 77 | }; |
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 { | |||
| 38 | return true; | 38 | return true; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | size_t VectorVfsFile::Read(u8* data_, size_t length, size_t offset) const { | 41 | std::size_t VectorVfsFile::Read(u8* data_, std::size_t length, std::size_t offset) const { |
| 42 | const auto read = std::min(length, data.size() - offset); | 42 | const auto read = std::min(length, data.size() - offset); |
| 43 | std::memcpy(data_, data.data() + offset, read); | 43 | std::memcpy(data_, data.data() + offset, read); |
| 44 | return read; | 44 | return read; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | size_t VectorVfsFile::Write(const u8* data_, size_t length, size_t offset) { | 47 | std::size_t VectorVfsFile::Write(const u8* data_, std::size_t length, std::size_t offset) { |
| 48 | if (offset + length > data.size()) | 48 | if (offset + length > data.size()) |
| 49 | data.resize(offset + length); | 49 | data.resize(offset + length); |
| 50 | const auto write = std::min(length, data.size() - offset); | 50 | 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: | |||
| 16 | ~VectorVfsFile() override; | 16 | ~VectorVfsFile() override; |
| 17 | 17 | ||
| 18 | std::string GetName() const override; | 18 | std::string GetName() const override; |
| 19 | size_t GetSize() const override; | 19 | std::size_t GetSize() const override; |
| 20 | bool Resize(size_t new_size) override; | 20 | bool Resize(std::size_t new_size) override; |
| 21 | std::shared_ptr<VfsDirectory> GetContainingDirectory() const override; | 21 | std::shared_ptr<VfsDirectory> GetContainingDirectory() const override; |
| 22 | bool IsWritable() const override; | 22 | bool IsWritable() const override; |
| 23 | bool IsReadable() const override; | 23 | bool IsReadable() const override; |
| 24 | size_t Read(u8* data, size_t length, size_t offset) const override; | 24 | std::size_t Read(u8* data, std::size_t length, std::size_t offset) const override; |
| 25 | size_t Write(const u8* data, size_t length, size_t offset) override; | 25 | std::size_t Write(const u8* data, std::size_t length, std::size_t offset) override; |
| 26 | bool Rename(std::string_view name) override; | 26 | bool Rename(std::string_view name) override; |
| 27 | 27 | ||
| 28 | virtual void Assign(std::vector<u8> new_data); | 28 | virtual void Assign(std::vector<u8> 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 | |||
| 760 | const auto path = fmt::format("{}{:016X}/romfs", | 760 | const auto path = fmt::format("{}{:016X}/romfs", |
| 761 | FileUtil::GetUserPath(FileUtil::UserPath::DumpDir), program_id); | 761 | FileUtil::GetUserPath(FileUtil::UserPath::DumpDir), program_id); |
| 762 | 762 | ||
| 763 | auto failed = [this, &path]() { | 763 | const auto failed = [this, &path] { |
| 764 | QMessageBox::warning(this, tr("RomFS Extraction Failed!"), | 764 | QMessageBox::warning(this, tr("RomFS Extraction Failed!"), |
| 765 | tr("There was an error copying the RomFS files or the user " | 765 | tr("There was an error copying the RomFS files or the user " |
| 766 | "cancelled the operation.")); | 766 | "cancelled the operation.")); |
| @@ -809,9 +809,9 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa | |||
| 809 | 809 | ||
| 810 | const auto full = res == "Full"; | 810 | const auto full = res == "Full"; |
| 811 | 811 | ||
| 812 | const static std::function<size_t(const FileSys::VirtualDir&, bool)> calculate_entry_size = | 812 | static const std::function<std::size_t(const FileSys::VirtualDir&, bool)> calculate_entry_size = |
| 813 | [](const FileSys::VirtualDir& dir, bool full) { | 813 | [](const FileSys::VirtualDir& dir, bool full) { |
| 814 | size_t out = 0; | 814 | std::size_t out = 0; |
| 815 | for (const auto& subdir : dir->GetSubdirectories()) | 815 | for (const auto& subdir : dir->GetSubdirectories()) |
| 816 | out += 1 + calculate_entry_size(subdir, full); | 816 | out += 1 + calculate_entry_size(subdir, full); |
| 817 | return out + full ? dir->GetFiles().size() : 0; | 817 | return out + full ? dir->GetFiles().size() : 0; |
| @@ -822,10 +822,10 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa | |||
| 822 | progress.setWindowModality(Qt::WindowModal); | 822 | progress.setWindowModality(Qt::WindowModal); |
| 823 | progress.setMinimumDuration(100); | 823 | progress.setMinimumDuration(100); |
| 824 | 824 | ||
| 825 | const static std::function<bool(QProgressDialog&, const FileSys::VirtualDir&, | 825 | static const std::function<bool(QProgressDialog&, const FileSys::VirtualDir&, |
| 826 | const FileSys::VirtualDir&, size_t, bool)> | 826 | const FileSys::VirtualDir&, std::size_t, bool)> |
| 827 | qt_raw_copy = [](QProgressDialog& dialog, const FileSys::VirtualDir& src, | 827 | qt_raw_copy = [](QProgressDialog& dialog, const FileSys::VirtualDir& src, |
| 828 | const FileSys::VirtualDir& dest, size_t block_size, bool full) { | 828 | const FileSys::VirtualDir& dest, std::size_t block_size, bool full) { |
| 829 | if (src == nullptr || dest == nullptr || !src->IsReadable() || !dest->IsWritable()) | 829 | if (src == nullptr || dest == nullptr || !src->IsReadable() || !dest->IsWritable()) |
| 830 | return false; | 830 | return false; |
| 831 | if (dialog.wasCanceled()) | 831 | if (dialog.wasCanceled()) |
| @@ -931,7 +931,7 @@ void GMainWindow::OnMenuInstallToNAND() { | |||
| 931 | } | 931 | } |
| 932 | 932 | ||
| 933 | const auto qt_raw_copy = [this](const FileSys::VirtualFile& src, | 933 | const auto qt_raw_copy = [this](const FileSys::VirtualFile& src, |
| 934 | const FileSys::VirtualFile& dest, size_t block_size) { | 934 | const FileSys::VirtualFile& dest, std::size_t block_size) { |
| 935 | if (src == nullptr || dest == nullptr) | 935 | if (src == nullptr || dest == nullptr) |
| 936 | return false; | 936 | return false; |
| 937 | if (!dest->Resize(src->GetSize())) | 937 | if (!dest->Resize(src->GetSize())) |