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.h27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/core/file_sys/vfs.h b/src/core/file_sys/vfs.h
index a5213e0cc..db3c77eac 100644
--- a/src/core/file_sys/vfs.h
+++ b/src/core/file_sys/vfs.h
@@ -59,8 +59,7 @@ struct VfsFile : NonCopyable {
59 // Returns the number of bytes (sizeof(T)*number_elements) read successfully. 59 // Returns the number of bytes (sizeof(T)*number_elements) read successfully.
60 template <typename T> 60 template <typename T>
61 size_t ReadArray(T* data, size_t number_elements, size_t offset = 0) const { 61 size_t ReadArray(T* data, size_t number_elements, size_t offset = 0) const {
62 static_assert(std::is_trivially_copyable<T>::value, 62 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable.");
63 "Data type must be trivially copyable.");
64 63
65 return Read(reinterpret_cast<u8*>(data), number_elements * sizeof(T), offset); 64 return Read(reinterpret_cast<u8*>(data), number_elements * sizeof(T), offset);
66 } 65 }
@@ -69,8 +68,7 @@ struct VfsFile : NonCopyable {
69 // Returns the number of bytes read successfully. 68 // Returns the number of bytes read successfully.
70 template <typename T> 69 template <typename T>
71 size_t ReadBytes(T* data, size_t size, size_t offset = 0) const { 70 size_t ReadBytes(T* data, size_t size, size_t offset = 0) const {
72 static_assert(std::is_trivially_copyable<T>::value, 71 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable.");
73 "Data type must be trivially copyable.");
74 return Read(reinterpret_cast<u8*>(data), size, offset); 72 return Read(reinterpret_cast<u8*>(data), size, offset);
75 } 73 }
76 74
@@ -78,8 +76,7 @@ struct VfsFile : NonCopyable {
78 // Returns the number of bytes read successfully (sizeof(T)). 76 // Returns the number of bytes read successfully (sizeof(T)).
79 template <typename T> 77 template <typename T>
80 size_t ReadObject(T* data, size_t offset = 0) const { 78 size_t ReadObject(T* data, size_t offset = 0) const {
81 static_assert(std::is_trivially_copyable<T>::value, 79 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable.");
82 "Data type must be trivially copyable.");
83 return Read(reinterpret_cast<u8*>(data), sizeof(T), offset); 80 return Read(reinterpret_cast<u8*>(data), sizeof(T), offset);
84 } 81 }
85 82
@@ -88,33 +85,29 @@ struct VfsFile : NonCopyable {
88 virtual bool WriteByte(u8 data, size_t offset = 0); 85 virtual bool WriteByte(u8 data, size_t offset = 0);
89 // Writes a vector of bytes to offset in file and returns the number of bytes successfully 86 // Writes a vector of bytes to offset in file and returns the number of bytes successfully
90 // written. 87 // written.
91 virtual size_t WriteBytes(std::vector<u8> data, size_t offset = 0); 88 virtual size_t WriteBytes(const std::vector<u8>& data, size_t offset = 0);
92 89
93 // Writes an array of type T, size number_elements to offset in file. 90 // Writes an array of type T, size number_elements to offset in file.
94 // Returns the number of bytes (sizeof(T)*number_elements) written successfully. 91 // Returns the number of bytes (sizeof(T)*number_elements) written successfully.
95 template <typename T> 92 template <typename T>
96 size_t WriteArray(T* data, size_t number_elements, size_t offset = 0) { 93 size_t WriteArray(const T* data, size_t number_elements, size_t offset = 0) {
97 static_assert(std::is_trivially_copyable<T>::value, 94 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable.");
98 "Data type must be trivially copyable.");
99
100 return Write(data, number_elements * sizeof(T), offset); 95 return Write(data, number_elements * sizeof(T), offset);
101 } 96 }
102 97
103 // Writes size bytes starting at memory location data to offset in file. 98 // Writes size bytes starting at memory location data to offset in file.
104 // Returns the number of bytes written successfully. 99 // Returns the number of bytes written successfully.
105 template <typename T> 100 template <typename T>
106 size_t WriteBytes(T* data, size_t size, size_t offset = 0) { 101 size_t WriteBytes(const T* data, size_t size, size_t offset = 0) {
107 static_assert(std::is_trivially_copyable<T>::value, 102 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable.");
108 "Data type must be trivially copyable."); 103 return Write(reinterpret_cast<const u8*>(data), size, offset);
109 return Write(reinterpret_cast<u8*>(data), size, offset);
110 } 104 }
111 105
112 // Writes one object of type T to offset in file. 106 // Writes one object of type T to offset in file.
113 // Returns the number of bytes written successfully (sizeof(T)). 107 // Returns the number of bytes written successfully (sizeof(T)).
114 template <typename T> 108 template <typename T>
115 size_t WriteObject(const T& data, size_t offset = 0) { 109 size_t WriteObject(const T& data, size_t offset = 0) {
116 static_assert(std::is_trivially_copyable<T>::value, 110 static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable.");
117 "Data type must be trivially copyable.");
118 return Write(&data, sizeof(T), offset); 111 return Write(&data, sizeof(T), offset);
119 } 112 }
120 113