diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2021-05-17 16:02:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-17 16:02:12 +0200 |
commit | b0a51bf9fe6b35cf4e2a76ec067d76349ca9b75c (patch) | |
tree | 905b5c483a9dab81bc19fbfe9893e17f02506720 /drivers/windows/file_access_windows.cpp | |
parent | 45e0f9fd523cb861b8e432966577d7c4608564ad (diff) | |
parent | 469fa47e0646d8f2ca3237dede8a04568039c7c6 (diff) | |
download | redot-engine-b0a51bf9fe6b35cf4e2a76ec067d76349ca9b75c.tar.gz |
Merge pull request #48768 from akien-mga/file-access-64-bit-4.0
Make all file access 64-bit (`uint64_t`)
Diffstat (limited to 'drivers/windows/file_access_windows.cpp')
-rw-r--r-- | drivers/windows/file_access_windows.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index b1b3fc9092..0f52c70482 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -193,10 +193,11 @@ bool FileAccessWindows::is_open() const { return (f != nullptr); } -void FileAccessWindows::seek(size_t p_position) { +void FileAccessWindows::seek(uint64_t p_position) { ERR_FAIL_COND(!f); + last_error = OK; - if (fseek(f, p_position, SEEK_SET)) { + if (_fseeki64(f, p_position, SEEK_SET)) { check_errors(); } prev_op = 0; @@ -204,28 +205,27 @@ void FileAccessWindows::seek(size_t p_position) { void FileAccessWindows::seek_end(int64_t p_position) { ERR_FAIL_COND(!f); - if (fseek(f, p_position, SEEK_END)) { + if (_fseeki64(f, p_position, SEEK_END)) { check_errors(); } prev_op = 0; } -size_t FileAccessWindows::get_position() const { - size_t aux_position = 0; - aux_position = ftell(f); - if (!aux_position) { +uint64_t FileAccessWindows::get_position() const { + int64_t aux_position = _ftelli64(f); + if (aux_position < 0) { check_errors(); } return aux_position; } -size_t FileAccessWindows::get_len() const { +uint64_t FileAccessWindows::get_len() const { ERR_FAIL_COND_V(!f, 0); - size_t pos = get_position(); - fseek(f, 0, SEEK_END); - int size = get_position(); - fseek(f, pos, SEEK_SET); + uint64_t pos = get_position(); + _fseeki64(f, 0, SEEK_END); + uint64_t size = get_position(); + _fseeki64(f, pos, SEEK_SET); return size; } @@ -252,17 +252,17 @@ uint8_t FileAccessWindows::get_8() const { return b; } -int FileAccessWindows::get_buffer(uint8_t *p_dst, int p_length) const { +uint64_t FileAccessWindows::get_buffer(uint8_t *p_dst, uint64_t p_length) const { ERR_FAIL_COND_V(!p_dst && p_length > 0, -1); - ERR_FAIL_COND_V(p_length < 0, -1); ERR_FAIL_COND_V(!f, -1); + if (flags == READ_WRITE || flags == WRITE_READ) { if (prev_op == WRITE) { fflush(f); } prev_op = READ; } - int read = fread(p_dst, 1, p_length, f); + uint64_t read = fread(p_dst, 1, p_length, f); check_errors(); return read; }; @@ -292,7 +292,7 @@ void FileAccessWindows::store_8(uint8_t p_dest) { fwrite(&p_dest, 1, 1, f); } -void FileAccessWindows::store_buffer(const uint8_t *p_src, int p_length) { +void FileAccessWindows::store_buffer(const uint8_t *p_src, uint64_t p_length) { ERR_FAIL_COND(!f); if (flags == READ_WRITE || flags == WRITE_READ) { if (prev_op == READ) { |