You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-23 15:16:17 +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
@@ -1029,12 +1029,12 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, c
|
||||
int header_padding = _get_pad(PCK_PADDING, header_size);
|
||||
|
||||
for (int i = 0; i < pd.file_ofs.size(); i++) {
|
||||
int string_len = pd.file_ofs[i].path_utf8.length();
|
||||
int pad = _get_pad(4, string_len);
|
||||
uint32_t string_len = pd.file_ofs[i].path_utf8.length();
|
||||
uint32_t pad = _get_pad(4, string_len);
|
||||
|
||||
f->store_32(string_len + pad);
|
||||
f->store_buffer((const uint8_t *)pd.file_ofs[i].path_utf8.get_data(), string_len);
|
||||
for (int j = 0; j < pad; j++) {
|
||||
for (uint32_t j = 0; j < pad; j++) {
|
||||
f->store_8(0);
|
||||
}
|
||||
|
||||
@@ -1060,8 +1060,8 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, c
|
||||
uint8_t buf[bufsize];
|
||||
|
||||
while (true) {
|
||||
int got = ftmp->get_buffer(buf, bufsize);
|
||||
if (got <= 0) {
|
||||
uint64_t got = ftmp->get_buffer(buf, bufsize);
|
||||
if (got == 0) {
|
||||
break;
|
||||
}
|
||||
f->store_buffer(buf, got);
|
||||
@@ -1071,13 +1071,13 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, c
|
||||
|
||||
if (p_embed) {
|
||||
// Ensure embedded data ends at a 64-bit multiple
|
||||
int64_t embed_end = f->get_position() - embed_pos + 12;
|
||||
int pad = embed_end % 8;
|
||||
for (int i = 0; i < pad; i++) {
|
||||
uint64_t embed_end = f->get_position() - embed_pos + 12;
|
||||
uint64_t pad = embed_end % 8;
|
||||
for (uint64_t i = 0; i < pad; i++) {
|
||||
f->store_8(0);
|
||||
}
|
||||
|
||||
int64_t pck_size = f->get_position() - pck_start_pos;
|
||||
uint64_t pck_size = f->get_position() - pck_start_pos;
|
||||
f->store_64(pck_size);
|
||||
f->store_32(PACK_HEADER_MAGIC);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user