You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Make all file access 64-bit (uint64_t)
This changes the types of a big number of variables. General rules: - Using `uint64_t` in general. We also considered `int64_t` but eventually settled on keeping it unsigned, which is also closer to what one would expect with `size_t`/`off_t`. - We only keep `int64_t` for `seek_end` (takes a negative offset from the end) and for the `Variant` bindings, since `Variant::INT` is `int64_t`. This means we only need to guard against passing negative values in `core_bind.cpp`. - Using `uint32_t` integers for concepts not needing such a huge range, like pages, blocks, etc. In addition: - Improve usage of integer types in some related places; namely, `DirAccess`, core binds. Note: - On Windows, `_ftelli64` reports invalid values when using 32-bit MinGW with version < 8.0. This was an upstream bug fixed in 8.0. It breaks support for big files on 32-bit Windows builds made with that toolchain. We might add a workaround. Fixes #44363. Fixes godotengine/godot-proposals#400. Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
This commit is contained in:
committed by
Rémi Verschelde
parent
9cc17a8439
commit
469fa47e06
@@ -71,8 +71,9 @@ bool FileAccessAndroid::is_open() const {
|
||||
return a != nullptr;
|
||||
}
|
||||
|
||||
void FileAccessAndroid::seek(size_t p_position) {
|
||||
void FileAccessAndroid::seek(uint64_t p_position) {
|
||||
ERR_FAIL_COND(!a);
|
||||
|
||||
AAsset_seek(a, p_position, SEEK_SET);
|
||||
pos = p_position;
|
||||
if (pos > len) {
|
||||
@@ -89,11 +90,11 @@ void FileAccessAndroid::seek_end(int64_t p_position) {
|
||||
pos = len + p_position;
|
||||
}
|
||||
|
||||
size_t FileAccessAndroid::get_position() const {
|
||||
uint64_t FileAccessAndroid::get_position() const {
|
||||
return pos;
|
||||
}
|
||||
|
||||
size_t FileAccessAndroid::get_len() const {
|
||||
uint64_t FileAccessAndroid::get_len() const {
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -113,11 +114,10 @@ uint8_t FileAccessAndroid::get_8() const {
|
||||
return byte;
|
||||
}
|
||||
|
||||
int FileAccessAndroid::get_buffer(uint8_t *p_dst, int p_length) const {
|
||||
uint64_t FileAccessAndroid::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);
|
||||
|
||||
off_t r = AAsset_read(a, p_dst, p_length);
|
||||
int r = AAsset_read(a, p_dst, p_length);
|
||||
|
||||
if (pos + p_length > len) {
|
||||
eof = true;
|
||||
|
||||
Reference in New Issue
Block a user