diff options
Diffstat (limited to 'src/core/file_sys')
-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 |
6 files changed, 23 insertions, 22 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<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; 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<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; }; 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<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); |