diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-09-02 12:12:42 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-09-02 12:12:42 +0200 |
commit | 527c716784fbca1f82dcfcaedaceb67ef85789a4 (patch) | |
tree | ac46fb161b36d3bb33c6f6fbcb4a2a33dbbcb058 /core/io/file_access_memory.cpp | |
parent | 9ff888bcd4ba74f94d5854ba9243d0f93a367f7a (diff) | |
parent | 205a10e0ae7bfff1bc6ebba481838e3ac856b6b8 (diff) | |
download | redot-engine-527c716784fbca1f82dcfcaedaceb67ef85789a4.tar.gz |
Merge pull request #92167 from BlueCube3310/file-access-the-final-season-part3-ep2
Reduce code duplication in FileAccess
Diffstat (limited to 'core/io/file_access_memory.cpp')
-rw-r--r-- | core/io/file_access_memory.cpp | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index 9521a4f666..1541a5ed4a 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -122,16 +122,6 @@ bool FileAccessMemory::eof_reached() const { return pos >= length; } -uint8_t FileAccessMemory::get_8() const { - uint8_t ret = 0; - if (pos < length) { - ret = data[pos]; - } - ++pos; - - return ret; -} - uint64_t FileAccessMemory::get_buffer(uint8_t *p_dst, uint64_t p_length) const { ERR_FAIL_COND_V(!p_dst && p_length > 0, -1); ERR_FAIL_NULL_V(data, -1); @@ -157,16 +147,12 @@ void FileAccessMemory::flush() { ERR_FAIL_NULL(data); } -void FileAccessMemory::store_8(uint8_t p_byte) { - ERR_FAIL_NULL(data); - ERR_FAIL_COND(pos >= length); - data[pos++] = p_byte; -} - void FileAccessMemory::store_buffer(const uint8_t *p_src, uint64_t p_length) { ERR_FAIL_COND(!p_src && p_length > 0); + uint64_t left = length - pos; uint64_t write = MIN(p_length, left); + if (write < p_length) { WARN_PRINT("Writing less data than requested"); } |