summaryrefslogtreecommitdiff
path: root/src/core/file_sys/vfs.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/file_sys/vfs.h')
-rw-r--r--src/core/file_sys/vfs.h32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/core/file_sys/vfs.h b/src/core/file_sys/vfs.h
index 5142a3e86..74489b452 100644
--- a/src/core/file_sys/vfs.h
+++ b/src/core/file_sys/vfs.h
@@ -92,9 +92,9 @@ public:
92 // Retrieves the extension of the file name. 92 // Retrieves the extension of the file name.
93 virtual std::string GetExtension() const; 93 virtual std::string GetExtension() const;
94 // Retrieves the size of the file. 94 // Retrieves the size of the file.
95 virtual size_t GetSize() const = 0; 95 virtual std::size_t GetSize() const = 0;
96 // Resizes the file to new_size. Returns whether or not the operation was successful. 96 // Resizes the file to new_size. Returns whether or not the operation was successful.
97 virtual bool Resize(size_t new_size) = 0; 97 virtual bool Resize(std::size_t new_size) = 0;
98 // Gets a pointer to the directory containing this file, returning nullptr if there is none. 98 // Gets a pointer to the directory containing this file, returning nullptr if there is none.
99 virtual std::shared_ptr<VfsDirectory> GetContainingDirectory() const = 0; 99 virtual std::shared_ptr<VfsDirectory> GetContainingDirectory() const = 0;
100 100
@@ -105,15 +105,15 @@ public:
105 105
106 // The primary method of reading from the file. Reads length bytes into data starting at offset 106 // The primary method of reading from the file. Reads length bytes into data starting at offset
107 // into file. Returns number of bytes successfully read. 107 // into file. Returns number of bytes successfully read.
108 virtual size_t Read(u8* data, size_t length, size_t offset = 0) const = 0; 108 virtual std::size_t Read(u8* data, std::size_t length, std::size_t offset = 0) const = 0;
109 // The primary method of writing to the file. Writes length bytes from data starting at offset 109 // The primary method of writing to the file. Writes length bytes from data starting at offset
110 // into file. Returns number of bytes successfully written. 110 // into file. Returns number of bytes successfully written.
111 virtual size_t Write(const u8* data, size_t length, size_t offset = 0) = 0; 111 virtual std::size_t Write(const u8* data, std::size_t length, std::size_t offset = 0) = 0;
112 112
113 // Reads exactly one byte at the offset provided, returning boost::none on error. 113 // Reads exactly one byte at the offset provided, returning boost::none on error.
114 virtual boost::optional<u8> ReadByte(size_t offset = 0) const; 114 virtual boost::optional<u8> ReadByte(std::size_t offset = 0) const;
115 // Reads size bytes starting at offset in file into a vector. 115 // Reads size bytes starting at offset in file into a vector.
116 virtual std::vector<u8> ReadBytes(size_t size, size_t offset = 0) const; 116 virtual std::vector<u8> ReadBytes(std::size_t size, std::size_t offset = 0) const;
117 // Reads all the bytes from the file into a vector. Equivalent to 'file->Read(file->GetSize(), 117 // Reads all the bytes from the file into a vector. Equivalent to 'file->Read(file->GetSize(),
118 // 0)' 118 // 0)'
119 virtual std::vector<u8> ReadAllBytes() const; 119 virtual std::vector<u8> ReadAllBytes() const;
@@ -121,7 +121,7 @@ public:
121 // Reads an array of type T, size number_elements starting at offset. 121 // Reads an array of type T, size number_elements starting at offset.
122 // Returns the number of bytes (sizeof(T)*number_elements) read successfully. 122 // Returns the number of bytes (sizeof(T)*number_elements) read successfully.
123 template <typename T> 123 template <typename T>
124 size_t ReadArray(T* data, size_t number_elements, size_t offset = 0) const { 124 std::size_t ReadArray(T* data, std::size_t number_elements, std::size_t offset = 0) const {
125 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable."); 125 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable.");
126 126
127 return Read(reinterpret_cast<u8*>(data), number_elements * sizeof(T), offset); 127 return Read(reinterpret_cast<u8*>(data), number_elements * sizeof(T), offset);
@@ -130,7 +130,7 @@ public:
130 // Reads size bytes into the memory starting at data starting at offset into the file. 130 // Reads size bytes into the memory starting at data starting at offset into the file.
131 // Returns the number of bytes read successfully. 131 // Returns the number of bytes read successfully.
132 template <typename T> 132 template <typename T>
133 size_t ReadBytes(T* data, size_t size, size_t offset = 0) const { 133 std::size_t ReadBytes(T* data, std::size_t size, std::size_t offset = 0) const {
134 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable."); 134 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable.");
135 return Read(reinterpret_cast<u8*>(data), size, offset); 135 return Read(reinterpret_cast<u8*>(data), size, offset);
136 } 136 }
@@ -138,22 +138,22 @@ public:
138 // Reads one object of type T starting at offset in file. 138 // Reads one object of type T starting at offset in file.
139 // Returns the number of bytes read successfully (sizeof(T)). 139 // Returns the number of bytes read successfully (sizeof(T)).
140 template <typename T> 140 template <typename T>
141 size_t ReadObject(T* data, size_t offset = 0) const { 141 std::size_t ReadObject(T* data, std::size_t offset = 0) const {
142 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable."); 142 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable.");
143 return Read(reinterpret_cast<u8*>(data), sizeof(T), offset); 143 return Read(reinterpret_cast<u8*>(data), sizeof(T), offset);
144 } 144 }
145 145
146 // Writes exactly one byte to offset in file and retuns whether or not the byte was written 146 // Writes exactly one byte to offset in file and retuns whether or not the byte was written
147 // successfully. 147 // successfully.
148 virtual bool WriteByte(u8 data, size_t offset = 0); 148 virtual bool WriteByte(u8 data, std::size_t offset = 0);
149 // Writes a vector of bytes to offset in file and returns the number of bytes successfully 149 // Writes a vector of bytes to offset in file and returns the number of bytes successfully
150 // written. 150 // written.
151 virtual size_t WriteBytes(const std::vector<u8>& data, size_t offset = 0); 151 virtual std::size_t WriteBytes(const std::vector<u8>& data, std::size_t offset = 0);
152 152
153 // Writes an array of type T, size number_elements to offset in file. 153 // Writes an array of type T, size number_elements to offset in file.
154 // Returns the number of bytes (sizeof(T)*number_elements) written successfully. 154 // Returns the number of bytes (sizeof(T)*number_elements) written successfully.
155 template <typename T> 155 template <typename T>
156 size_t WriteArray(const T* data, size_t number_elements, size_t offset = 0) { 156 std::size_t WriteArray(const T* data, std::size_t number_elements, std::size_t offset = 0) {
157 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable."); 157 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable.");
158 return Write(data, number_elements * sizeof(T), offset); 158 return Write(data, number_elements * sizeof(T), offset);
159 } 159 }
@@ -161,7 +161,7 @@ public:
161 // Writes size bytes starting at memory location data to offset in file. 161 // Writes size bytes starting at memory location data to offset in file.
162 // Returns the number of bytes written successfully. 162 // Returns the number of bytes written successfully.
163 template <typename T> 163 template <typename T>
164 size_t WriteBytes(const T* data, size_t size, size_t offset = 0) { 164 std::size_t WriteBytes(const T* data, std::size_t size, std::size_t offset = 0) {
165 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable."); 165 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable.");
166 return Write(reinterpret_cast<const u8*>(data), size, offset); 166 return Write(reinterpret_cast<const u8*>(data), size, offset);
167 } 167 }
@@ -169,7 +169,7 @@ public:
169 // Writes one object of type T to offset in file. 169 // Writes one object of type T to offset in file.
170 // Returns the number of bytes written successfully (sizeof(T)). 170 // Returns the number of bytes written successfully (sizeof(T)).
171 template <typename T> 171 template <typename T>
172 size_t WriteObject(const T& data, size_t offset = 0) { 172 std::size_t WriteObject(const T& data, std::size_t offset = 0) {
173 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable."); 173 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable.");
174 return Write(&data, sizeof(T), offset); 174 return Write(&data, sizeof(T), offset);
175 } 175 }
@@ -221,7 +221,7 @@ public:
221 // Returns the name of the directory. 221 // Returns the name of the directory.
222 virtual std::string GetName() const = 0; 222 virtual std::string GetName() const = 0;
223 // Returns the total size of all files and subdirectories in this directory. 223 // Returns the total size of all files and subdirectories in this directory.
224 virtual size_t GetSize() const; 224 virtual std::size_t GetSize() const;
225 // Returns the parent directory of this directory. Returns nullptr if this directory is root or 225 // Returns the parent directory of this directory. Returns nullptr if this directory is root or
226 // has no parent. 226 // has no parent.
227 virtual std::shared_ptr<VfsDirectory> GetParentDirectory() const = 0; 227 virtual std::shared_ptr<VfsDirectory> GetParentDirectory() const = 0;
@@ -311,7 +311,7 @@ public:
311}; 311};
312 312
313// Compare the two files, byte-for-byte, in increments specificed by block_size 313// Compare the two files, byte-for-byte, in increments specificed by block_size
314bool DeepEquals(const VirtualFile& file1, const VirtualFile& file2, size_t block_size = 0x200); 314bool DeepEquals(const VirtualFile& file1, const VirtualFile& file2, std::size_t block_size = 0x200);
315 315
316// A method that copies the raw data between two different implementations of VirtualFile. If you 316// A method that copies the raw data between two different implementations of VirtualFile. If you
317// are using the same implementation, it is probably better to use the Copy method in the parent 317// are using the same implementation, it is probably better to use the Copy method in the parent