You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +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
74174676b8
commit
817ffc01e1
@@ -67,7 +67,7 @@ static long godot_tell(voidpf opaque, voidpf stream) {
|
||||
static long godot_seek(voidpf opaque, voidpf stream, uLong offset, int origin) {
|
||||
FileAccess *f = (FileAccess *)stream;
|
||||
|
||||
int pos = offset;
|
||||
uint64_t pos = offset;
|
||||
switch (origin) {
|
||||
case ZLIB_FILEFUNC_SEEK_CUR:
|
||||
pos = f->get_position() + offset;
|
||||
@@ -145,7 +145,7 @@ unzFile ZipArchive::get_file_handle(String p_file) const {
|
||||
return pkg;
|
||||
}
|
||||
|
||||
bool ZipArchive::try_open_pack(const String &p_path, bool p_replace_files, size_t p_offset = 0) {
|
||||
bool ZipArchive::try_open_pack(const String &p_path, bool p_replace_files, uint64_t p_offset = 0) {
|
||||
//printf("opening zip pack %ls, %i, %i\n", p_name.c_str(), p_name.extension().nocasecmp_to("zip"), p_name.extension().nocasecmp_to("pcz"));
|
||||
// load with offset feature only supported for PCK files
|
||||
ERR_FAIL_COND_V_MSG(p_offset != 0, false, "Invalid PCK data. Note that loading files with a non-zero offset isn't supported with ZIP archives.");
|
||||
@@ -267,8 +267,9 @@ bool FileAccessZip::is_open() const {
|
||||
return zfile != nullptr;
|
||||
}
|
||||
|
||||
void FileAccessZip::seek(size_t p_position) {
|
||||
void FileAccessZip::seek(uint64_t p_position) {
|
||||
ERR_FAIL_COND(!zfile);
|
||||
|
||||
unzSeekCurrentFile(zfile, p_position);
|
||||
}
|
||||
|
||||
@@ -277,12 +278,12 @@ void FileAccessZip::seek_end(int64_t p_position) {
|
||||
unzSeekCurrentFile(zfile, get_len() + p_position);
|
||||
}
|
||||
|
||||
size_t FileAccessZip::get_position() const {
|
||||
uint64_t FileAccessZip::get_position() const {
|
||||
ERR_FAIL_COND_V(!zfile, 0);
|
||||
return unztell(zfile);
|
||||
}
|
||||
|
||||
size_t FileAccessZip::get_len() const {
|
||||
uint64_t FileAccessZip::get_len() const {
|
||||
ERR_FAIL_COND_V(!zfile, 0);
|
||||
return file_info.uncompressed_size;
|
||||
}
|
||||
@@ -299,17 +300,17 @@ uint8_t FileAccessZip::get_8() const {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int FileAccessZip::get_buffer(uint8_t *p_dst, int p_length) const {
|
||||
uint64_t FileAccessZip::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(!zfile, -1);
|
||||
|
||||
at_eof = unzeof(zfile);
|
||||
if (at_eof) {
|
||||
return 0;
|
||||
}
|
||||
int read = unzReadCurrentFile(zfile, p_dst, p_length);
|
||||
int64_t read = unzReadCurrentFile(zfile, p_dst, p_length);
|
||||
ERR_FAIL_COND_V(read < 0, read);
|
||||
if (read < p_length) {
|
||||
if ((uint64_t)read < p_length) {
|
||||
at_eof = true;
|
||||
}
|
||||
return read;
|
||||
|
||||
Reference in New Issue
Block a user