From da5d7db6100955922e08ee99a02f827214ed8281 Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Tue, 25 May 2021 07:58:49 +0100 Subject: [PATCH] Rename File::get_len() get_length() --- core/core_bind.cpp | 8 +++---- core/core_bind.h | 2 +- core/io/file_access_compressed.cpp | 2 +- core/io/file_access_compressed.h | 2 +- core/io/file_access_encrypted.cpp | 22 +++++++++---------- core/io/file_access_encrypted.h | 2 +- core/io/file_access_memory.cpp | 2 +- core/io/file_access_memory.h | 2 +- core/io/file_access_network.cpp | 2 +- core/io/file_access_network.h | 2 +- core/io/file_access_pack.cpp | 2 +- core/io/file_access_pack.h | 2 +- core/io/file_access_zip.cpp | 6 ++--- core/io/file_access_zip.h | 2 +- core/io/pck_packer.cpp | 2 +- core/io/xml_parser.cpp | 2 +- core/io/zip_io.cpp | 2 +- core/os/file_access.cpp | 4 ++-- core/os/file_access.h | 2 +- doc/classes/File.xml | 8 +++---- drivers/png/image_loader_png.cpp | 2 +- drivers/unix/file_access_unix.cpp | 2 +- drivers/unix/file_access_unix.h | 2 +- drivers/windows/file_access_windows.cpp | 2 +- drivers/windows/file_access_windows.h | 2 +- editor/fileserver/editor_file_server.cpp | 2 +- editor/import/resource_importer_image.cpp | 2 +- modules/bmp/image_loader_bmp.cpp | 2 +- modules/fbx/editor_scene_importer_fbx.cpp | 2 +- .../pluginscript/pluginscript_script.cpp | 2 +- .../videodecoder/video_stream_gdnative.cpp | 2 +- modules/gdscript/gdscript.cpp | 2 +- modules/gdscript/gdscript_cache.cpp | 2 +- modules/gdscript/tests/test_gdscript.cpp | 4 ++-- modules/gltf/gltf_document.cpp | 2 +- modules/jpg/image_loader_jpegd.cpp | 2 +- modules/mbedtls/crypto_mbedtls.cpp | 4 ++-- modules/minimp3/resource_importer_mp3.cpp | 2 +- modules/mono/utils/string_utils.cpp | 2 +- .../resource_importer_ogg_vorbis.cpp | 2 +- modules/svg/image_loader_svg.cpp | 2 +- modules/text_server_adv/dynamic_font_adv.cpp | 2 +- modules/text_server_adv/text_server_adv.cpp | 2 +- modules/text_server_fb/dynamic_font_fb.cpp | 2 +- modules/tga/image_loader_tga.cpp | 2 +- modules/tinyexr/image_loader_tinyexr.cpp | 2 +- modules/webm/video_stream_webm.cpp | 2 +- modules/webp/image_loader_webp.cpp | 2 +- platform/android/file_access_android.cpp | 2 +- platform/android/file_access_android.h | 2 +- .../api/javascript_tools_editor_plugin.cpp | 4 ++-- platform/javascript/export/export.cpp | 8 +++---- platform/osx/display_server_osx.mm | 2 +- platform/osx/export/export.cpp | 6 ++--- platform/uwp/export/export.cpp | 6 ++--- scene/resources/text_file.cpp | 2 +- tests/test_image.h | 20 ++++++++--------- tests/test_math.cpp | 4 ++-- tests/test_pck_packer.h | 8 +++---- 59 files changed, 101 insertions(+), 101 deletions(-) diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 63238e3029..b8c448dc82 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -1272,9 +1272,9 @@ uint64_t _File::get_position() const { return f->get_position(); } -uint64_t _File::get_len() const { +uint64_t _File::get_length() const { ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use."); - return f->get_len(); + return f->get_length(); } bool _File::eof_reached() const { @@ -1536,7 +1536,7 @@ void _File::_bind_methods() { ClassDB::bind_method(D_METHOD("seek", "position"), &_File::seek); ClassDB::bind_method(D_METHOD("seek_end", "position"), &_File::seek_end, DEFVAL(0)); ClassDB::bind_method(D_METHOD("get_position"), &_File::get_position); - ClassDB::bind_method(D_METHOD("get_len"), &_File::get_len); + ClassDB::bind_method(D_METHOD("get_length"), &_File::get_length); ClassDB::bind_method(D_METHOD("eof_reached"), &_File::eof_reached); ClassDB::bind_method(D_METHOD("get_8"), &_File::get_8); ClassDB::bind_method(D_METHOD("get_16"), &_File::get_16); @@ -1545,7 +1545,7 @@ void _File::_bind_methods() { ClassDB::bind_method(D_METHOD("get_float"), &_File::get_float); ClassDB::bind_method(D_METHOD("get_double"), &_File::get_double); ClassDB::bind_method(D_METHOD("get_real"), &_File::get_real); - ClassDB::bind_method(D_METHOD("get_buffer", "len"), &_File::get_buffer); + ClassDB::bind_method(D_METHOD("get_buffer", "length"), &_File::get_buffer); ClassDB::bind_method(D_METHOD("get_line"), &_File::get_line); ClassDB::bind_method(D_METHOD("get_csv_line", "delim"), &_File::get_csv_line, DEFVAL(",")); ClassDB::bind_method(D_METHOD("get_as_text"), &_File::get_as_text); diff --git a/core/core_bind.h b/core/core_bind.h index 8bd96d8268..be8b30b38d 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -391,7 +391,7 @@ public: void seek(int64_t p_position); // Seek to a given position. void seek_end(int64_t p_position = 0); // Seek from the end of file. uint64_t get_position() const; // Get position in the file. - uint64_t get_len() const; // Get size of the file. + uint64_t get_length() const; // Get size of the file. bool eof_reached() const; // Reading passed EOF. diff --git a/core/io/file_access_compressed.cpp b/core/io/file_access_compressed.cpp index efcaa80fc5..e54c947340 100644 --- a/core/io/file_access_compressed.cpp +++ b/core/io/file_access_compressed.cpp @@ -237,7 +237,7 @@ uint64_t FileAccessCompressed::get_position() const { } } -uint64_t FileAccessCompressed::get_len() const { +uint64_t FileAccessCompressed::get_length() const { ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use."); if (writing) { return write_max; diff --git a/core/io/file_access_compressed.h b/core/io/file_access_compressed.h index d8a81c2417..19e4f241dd 100644 --- a/core/io/file_access_compressed.h +++ b/core/io/file_access_compressed.h @@ -75,7 +75,7 @@ public: virtual void seek(uint64_t p_position); ///< seek to a given position virtual void seek_end(int64_t p_position = 0); ///< seek from the end of file virtual uint64_t get_position() const; ///< get position in the file - virtual uint64_t get_len() const; ///< get size of the file + virtual uint64_t get_length() const; ///< get size of the file virtual bool eof_reached() const; ///< reading passed EOF diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp index 9a6bee7348..b9514c8c8b 100644 --- a/core/io/file_access_encrypted.cpp +++ b/core/io/file_access_encrypted.cpp @@ -69,7 +69,7 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vectorget_position(); - ERR_FAIL_COND_V(p_base->get_len() < base + length, ERR_FILE_CORRUPT); + ERR_FAIL_COND_V(p_base->get_length() < base + length, ERR_FILE_CORRUPT); uint64_t ds = length; if (ds % 16) { ds += 16 - (ds % 16); @@ -199,8 +199,8 @@ String FileAccessEncrypted::get_path_absolute() const { } void FileAccessEncrypted::seek(uint64_t p_position) { - if (p_position > get_len()) { - p_position = get_len(); + if (p_position > get_length()) { + p_position = get_length(); } pos = p_position; @@ -208,14 +208,14 @@ void FileAccessEncrypted::seek(uint64_t p_position) { } void FileAccessEncrypted::seek_end(int64_t p_position) { - seek(get_len() + p_position); + seek(get_length() + p_position); } uint64_t FileAccessEncrypted::get_position() const { return pos; } -uint64_t FileAccessEncrypted::get_len() const { +uint64_t FileAccessEncrypted::get_length() const { return data.size(); } @@ -225,7 +225,7 @@ bool FileAccessEncrypted::eof_reached() const { uint8_t FileAccessEncrypted::get_8() const { ERR_FAIL_COND_V_MSG(writing, 0, "File has not been opened in read mode."); - if (pos >= get_len()) { + if (pos >= get_length()) { eofed = true; return 0; } @@ -239,7 +239,7 @@ uint64_t FileAccessEncrypted::get_buffer(uint8_t *p_dst, uint64_t p_length) cons ERR_FAIL_COND_V(!p_dst && p_length > 0, -1); ERR_FAIL_COND_V_MSG(writing, -1, "File has not been opened in read mode."); - uint64_t to_copy = MIN(p_length, get_len() - pos); + uint64_t to_copy = MIN(p_length, get_length() - pos); for (uint64_t i = 0; i < to_copy; i++) { p_dst[i] = data[pos++]; } @@ -258,11 +258,11 @@ Error FileAccessEncrypted::get_error() const { void FileAccessEncrypted::store_buffer(const uint8_t *p_src, uint64_t p_length) { ERR_FAIL_COND_MSG(!writing, "File has not been opened in write mode."); - if (pos < get_len()) { + if (pos < get_length()) { for (uint64_t i = 0; i < p_length; i++) { store_8(p_src[i]); } - } else if (pos == get_len()) { + } else if (pos == get_length()) { data.resize(pos + p_length); for (uint64_t i = 0; i < p_length; i++) { data.write[pos + i] = p_src[i]; @@ -280,10 +280,10 @@ void FileAccessEncrypted::flush() { void FileAccessEncrypted::store_8(uint8_t p_dest) { ERR_FAIL_COND_MSG(!writing, "File has not been opened in write mode."); - if (pos < get_len()) { + if (pos < get_length()) { data.write[pos] = p_dest; pos++; - } else if (pos == get_len()) { + } else if (pos == get_length()) { data.push_back(p_dest); pos++; } diff --git a/core/io/file_access_encrypted.h b/core/io/file_access_encrypted.h index 8bea8c2585..00f14099f9 100644 --- a/core/io/file_access_encrypted.h +++ b/core/io/file_access_encrypted.h @@ -71,7 +71,7 @@ public: virtual void seek(uint64_t p_position); ///< seek to a given position virtual void seek_end(int64_t p_position = 0); ///< seek from the end of file virtual uint64_t get_position() const; ///< get position in the file - virtual uint64_t get_len() const; ///< get size of the file + virtual uint64_t get_length() const; ///< get size of the file virtual bool eof_reached() const; ///< reading passed EOF diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index 14e24d6668..0114ab1765 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -117,7 +117,7 @@ uint64_t FileAccessMemory::get_position() const { return pos; } -uint64_t FileAccessMemory::get_len() const { +uint64_t FileAccessMemory::get_length() const { ERR_FAIL_COND_V(!data, 0); return length; } diff --git a/core/io/file_access_memory.h b/core/io/file_access_memory.h index cc589dc259..4157531d01 100644 --- a/core/io/file_access_memory.h +++ b/core/io/file_access_memory.h @@ -52,7 +52,7 @@ public: virtual void seek(uint64_t p_position); ///< seek to a given position virtual void seek_end(int64_t p_position); ///< seek from the end of file virtual uint64_t get_position() const; ///< get position in the file - virtual uint64_t get_len() const; ///< get size of the file + virtual uint64_t get_length() const; ///< get size of the file virtual bool eof_reached() const; ///< reading passed EOF diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp index dedd5523ed..63a8f9c5b6 100644 --- a/core/io/file_access_network.cpp +++ b/core/io/file_access_network.cpp @@ -328,7 +328,7 @@ uint64_t FileAccessNetwork::get_position() const { return pos; } -uint64_t FileAccessNetwork::get_len() const { +uint64_t FileAccessNetwork::get_length() const { ERR_FAIL_COND_V_MSG(!opened, 0, "File must be opened before use."); return total_size; } diff --git a/core/io/file_access_network.h b/core/io/file_access_network.h index 4810cca195..94b66c2480 100644 --- a/core/io/file_access_network.h +++ b/core/io/file_access_network.h @@ -137,7 +137,7 @@ public: virtual void seek(uint64_t p_position); ///< seek to a given position virtual void seek_end(int64_t p_position = 0); ///< seek from the end of file virtual uint64_t get_position() const; ///< get position in the file - virtual uint64_t get_len() const; ///< get size of the file + virtual uint64_t get_length() const; ///< get size of the file virtual bool eof_reached() const; ///< reading passed EOF diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index 3e1c51b733..e9983ece47 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -279,7 +279,7 @@ uint64_t FileAccessPack::get_position() const { return pos; } -uint64_t FileAccessPack::get_len() const { +uint64_t FileAccessPack::get_length() const { return pf.size; } diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 763c0fb327..9747e865c8 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -163,7 +163,7 @@ public: virtual void seek(uint64_t p_position); virtual void seek_end(int64_t p_position = 0); virtual uint64_t get_position() const; - virtual uint64_t get_len() const; + virtual uint64_t get_length() const; virtual bool eof_reached() const; diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp index d7ff1b7e00..b8383fd865 100644 --- a/core/io/file_access_zip.cpp +++ b/core/io/file_access_zip.cpp @@ -73,7 +73,7 @@ static long godot_seek(voidpf opaque, voidpf stream, uLong offset, int origin) { pos = f->get_position() + offset; break; case ZLIB_FILEFUNC_SEEK_END: - pos = f->get_len() + offset; + pos = f->get_length() + offset; break; default: break; @@ -270,7 +270,7 @@ void FileAccessZip::seek(uint64_t p_position) { void FileAccessZip::seek_end(int64_t p_position) { ERR_FAIL_COND(!zfile); - unzSeekCurrentFile(zfile, get_len() + p_position); + unzSeekCurrentFile(zfile, get_length() + p_position); } uint64_t FileAccessZip::get_position() const { @@ -278,7 +278,7 @@ uint64_t FileAccessZip::get_position() const { return unztell(zfile); } -uint64_t FileAccessZip::get_len() const { +uint64_t FileAccessZip::get_length() const { ERR_FAIL_COND_V(!zfile, 0); return file_info.uncompressed_size; } diff --git a/core/io/file_access_zip.h b/core/io/file_access_zip.h index 91bdaafb68..cca14ded62 100644 --- a/core/io/file_access_zip.h +++ b/core/io/file_access_zip.h @@ -90,7 +90,7 @@ public: virtual void seek(uint64_t p_position); ///< seek to a given position virtual void seek_end(int64_t p_position = 0); ///< seek from the end of file virtual uint64_t get_position() const; ///< get position in the file - virtual uint64_t get_len() const; ///< get size of the file + virtual uint64_t get_length() const; ///< get size of the file virtual bool eof_reached() const; ///< reading passed EOF diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp index 4fe22e57d8..cadb02b5dd 100644 --- a/core/io/pck_packer.cpp +++ b/core/io/pck_packer.cpp @@ -120,7 +120,7 @@ Error PCKPacker::add_file(const String &p_file, const String &p_src, bool p_encr pf.path = p_file; pf.src_path = p_src; pf.ofs = ofs; - pf.size = f->get_len(); + pf.size = f->get_length(); Vector data = FileAccess::get_file_as_array(p_src); { diff --git a/core/io/xml_parser.cpp b/core/io/xml_parser.cpp index f3ce2319e3..938d93a01b 100644 --- a/core/io/xml_parser.cpp +++ b/core/io/xml_parser.cpp @@ -476,7 +476,7 @@ Error XMLParser::open(const String &p_path) { ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot open file '" + p_path + "'."); - length = file->get_len(); + length = file->get_length(); ERR_FAIL_COND_V(length < 1, ERR_FILE_CORRUPT); if (data) { diff --git a/core/io/zip_io.cpp b/core/io/zip_io.cpp index e0e491dc85..fb4c76aa7a 100644 --- a/core/io/zip_io.cpp +++ b/core/io/zip_io.cpp @@ -74,7 +74,7 @@ long zipio_seek(voidpf opaque, voidpf stream, uLong offset, int origin) { pos = f->get_position() + offset; break; case ZLIB_FILEFUNC_SEEK_END: - pos = f->get_len() + offset; + pos = f->get_length() + offset; break; default: break; diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index d00d0ac5bb..d1b940190a 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -380,7 +380,7 @@ uint64_t FileAccess::get_buffer(uint8_t *p_dst, uint64_t p_length) const { String FileAccess::get_as_utf8_string() const { Vector sourcef; - uint64_t len = get_len(); + uint64_t len = get_length(); sourcef.resize(len + 1); uint8_t *w = sourcef.ptrw(); @@ -565,7 +565,7 @@ Vector FileAccess::get_file_as_array(const String &p_path, Error *r_err ERR_FAIL_V_MSG(Vector(), "Can't open file from path '" + String(p_path) + "'."); } Vector data; - data.resize(f->get_len()); + data.resize(f->get_length()); f->get_buffer(data.ptrw(), data.size()); memdelete(f); return data; diff --git a/core/os/file_access.h b/core/os/file_access.h index f9749c0fd1..1b9fb2f422 100644 --- a/core/os/file_access.h +++ b/core/os/file_access.h @@ -96,7 +96,7 @@ public: virtual void seek(uint64_t p_position) = 0; ///< seek to a given position virtual void seek_end(int64_t p_position = 0) = 0; ///< seek from the end of file with negative offset virtual uint64_t get_position() const = 0; ///< get position in the file - virtual uint64_t get_len() const = 0; ///< get size of the file + virtual uint64_t get_length() const = 0; ///< get size of the file virtual bool eof_reached() const = 0; ///< reading passed EOF diff --git a/doc/classes/File.xml b/doc/classes/File.xml index f0b9156b89..2206730523 100644 --- a/doc/classes/File.xml +++ b/doc/classes/File.xml @@ -61,7 +61,7 @@ Returns [code]true[/code] if the file cursor has read past the end of the file. - [b]Note:[/b] This function will still return [code]false[/code] while at the end of the file and only activates when reading past it. This can be confusing but it conforms to how low-level file access works in all operating systems. There is always [method get_len] and [method get_position] to implement a custom logic. + [b]Note:[/b] This function will still return [code]false[/code] while at the end of the file and only activates when reading past it. This can be confusing but it conforms to how low-level file access works in all operating systems. There is always [method get_length] and [method get_position] to implement a custom logic. @@ -121,10 +121,10 @@ - + - Returns next [code]len[/code] bytes of the file as a [PackedByteArray]. + Returns next [code]length[/code] bytes of the file as a [PackedByteArray]. @@ -158,7 +158,7 @@ Returns the next 32 bits from the file as a floating-point number. - + diff --git a/drivers/png/image_loader_png.cpp b/drivers/png/image_loader_png.cpp index 41554bc93f..8b2e786146 100644 --- a/drivers/png/image_loader_png.cpp +++ b/drivers/png/image_loader_png.cpp @@ -37,7 +37,7 @@ #include Error ImageLoaderPNG::load_image(Ref p_image, FileAccess *f, bool p_force_linear, float p_scale) { - const uint64_t buffer_size = f->get_len(); + const uint64_t buffer_size = f->get_length(); Vector file_buffer; Error err = file_buffer.resize(buffer_size); if (err) { diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp index de9a7867ee..ec23df62d0 100644 --- a/drivers/unix/file_access_unix.cpp +++ b/drivers/unix/file_access_unix.cpp @@ -212,7 +212,7 @@ uint64_t FileAccessUnix::get_position() const { return pos; } -uint64_t FileAccessUnix::get_len() const { +uint64_t FileAccessUnix::get_length() const { ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use."); int64_t pos = ftello(f); diff --git a/drivers/unix/file_access_unix.h b/drivers/unix/file_access_unix.h index 6aa3e1529f..5b1599c67f 100644 --- a/drivers/unix/file_access_unix.h +++ b/drivers/unix/file_access_unix.h @@ -64,7 +64,7 @@ public: virtual void seek(uint64_t p_position); ///< seek to a given position virtual void seek_end(int64_t p_position = 0); ///< seek from the end of file virtual uint64_t get_position() const; ///< get position in the file - virtual uint64_t get_len() const; ///< get size of the file + virtual uint64_t get_length() const; ///< get size of the file virtual bool eof_reached() const; ///< reading passed EOF diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index 0f52c70482..1f46b44f5e 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -219,7 +219,7 @@ uint64_t FileAccessWindows::get_position() const { return aux_position; } -uint64_t FileAccessWindows::get_len() const { +uint64_t FileAccessWindows::get_length() const { ERR_FAIL_COND_V(!f, 0); uint64_t pos = get_position(); diff --git a/drivers/windows/file_access_windows.h b/drivers/windows/file_access_windows.h index 008c69de66..95f3a75548 100644 --- a/drivers/windows/file_access_windows.h +++ b/drivers/windows/file_access_windows.h @@ -59,7 +59,7 @@ public: virtual void seek(uint64_t p_position); ///< seek to a given position virtual void seek_end(int64_t p_position = 0); ///< seek from the end of file virtual uint64_t get_position() const; ///< get position in the file - virtual uint64_t get_len() const; ///< get size of the file + virtual uint64_t get_length() const; ///< get size of the file virtual bool eof_reached() const; ///< reading passed EOF diff --git a/editor/fileserver/editor_file_server.cpp b/editor/fileserver/editor_file_server.cpp index b04e518b0b..654915e3e5 100644 --- a/editor/fileserver/editor_file_server.cpp +++ b/editor/fileserver/editor_file_server.cpp @@ -200,7 +200,7 @@ void EditorFileServer::_subthread_start(void *s) { cd->connection->put_data(buf4, 4); encode_uint32(OK, buf4); cd->connection->put_data(buf4, 4); - encode_uint64(fa->get_len(), buf4); + encode_uint64(fa->get_length(), buf4); cd->connection->put_data(buf4, 8); cd->files[id] = fa; diff --git a/editor/import/resource_importer_image.cpp b/editor/import/resource_importer_image.cpp index fa6ce5fc89..c5b2a8dc3a 100644 --- a/editor/import/resource_importer_image.cpp +++ b/editor/import/resource_importer_image.cpp @@ -75,7 +75,7 @@ Error ResourceImporterImage::import(const String &p_source_file, const String &p ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, "Cannot open file from path '" + p_source_file + "'."); - uint64_t len = f->get_len(); + uint64_t len = f->get_length(); Vector data; data.resize(len); diff --git a/modules/bmp/image_loader_bmp.cpp b/modules/bmp/image_loader_bmp.cpp index f22e74cafb..27b49a6609 100644 --- a/modules/bmp/image_loader_bmp.cpp +++ b/modules/bmp/image_loader_bmp.cpp @@ -205,7 +205,7 @@ Error ImageLoaderBMP::load_image(Ref p_image, FileAccess *f, // A valid bmp file should always at least have a // file header and a minimal info header - if (f->get_len() > BITMAP_FILE_HEADER_SIZE + BITMAP_INFO_HEADER_MIN_SIZE) { + if (f->get_length() > BITMAP_FILE_HEADER_SIZE + BITMAP_INFO_HEADER_MIN_SIZE) { // File Header bmp_header.bmp_file_header.bmp_signature = f->get_16(); if (bmp_header.bmp_file_header.bmp_signature == BITMAP_SIGNATURE) { diff --git a/modules/fbx/editor_scene_importer_fbx.cpp b/modules/fbx/editor_scene_importer_fbx.cpp index 58bc450e9d..f60277f60a 100644 --- a/modules/fbx/editor_scene_importer_fbx.cpp +++ b/modules/fbx/editor_scene_importer_fbx.cpp @@ -102,7 +102,7 @@ Node3D *EditorSceneImporterFBX::import_scene(const String &p_path, uint32_t p_fl FBXDocParser::TokenList tokens; bool is_binary = false; - data.resize(f->get_len()); + data.resize(f->get_length()); ERR_FAIL_COND_V(data.size() < 64, nullptr); diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp index a0d7fbf726..93fe3b3992 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.cpp +++ b/modules/gdnative/pluginscript/pluginscript_script.cpp @@ -441,7 +441,7 @@ Error PluginScript::load_source_code(const String &p_path) { FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err); ERR_FAIL_COND_V_MSG(err, err, "Cannot open file '" + p_path + "'."); - uint64_t len = f->get_len(); + uint64_t len = f->get_length(); sourcef.resize(len + 1); uint8_t *w = sourcef.ptrw(); uint64_t r = f->get_buffer(w, len); diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.cpp b/modules/gdnative/videodecoder/video_stream_gdnative.cpp index 1b7838846f..8b0434c7dd 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.cpp +++ b/modules/gdnative/videodecoder/video_stream_gdnative.cpp @@ -58,7 +58,7 @@ int64_t GDAPI godot_videodecoder_file_seek(void *ptr, int64_t pos, int whence) { FileAccess *file = reinterpret_cast(ptr); if (file) { - int64_t len = file->get_len(); + int64_t len = file->get_length(); switch (whence) { case SEEK_SET: { if (pos > len) { diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 2896420239..d7814e85b0 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -1045,7 +1045,7 @@ Error GDScript::load_source_code(const String &p_path) { ERR_FAIL_COND_V(err, err); } - uint64_t len = f->get_len(); + uint64_t len = f->get_length(); sourcef.resize(len + 1); uint8_t *w = sourcef.ptrw(); uint64_t r = f->get_buffer(w, len); diff --git a/modules/gdscript/gdscript_cache.cpp b/modules/gdscript/gdscript_cache.cpp index 6aa76703f1..601cdb4080 100644 --- a/modules/gdscript/gdscript_cache.cpp +++ b/modules/gdscript/gdscript_cache.cpp @@ -153,7 +153,7 @@ String GDScriptCache::get_source_code(const String &p_path) { ERR_FAIL_COND_V(err, ""); } - uint64_t len = f->get_len(); + uint64_t len = f->get_length(); source_file.resize(len + 1); uint64_t r = f->get_buffer(source_file.ptrw(), len); f->close(); diff --git a/modules/gdscript/tests/test_gdscript.cpp b/modules/gdscript/tests/test_gdscript.cpp index 8ad5cdacad..fc73b5bb72 100644 --- a/modules/gdscript/tests/test_gdscript.cpp +++ b/modules/gdscript/tests/test_gdscript.cpp @@ -215,8 +215,8 @@ void test(TestType p_type) { init_language(fa->get_path_absolute().get_base_dir()); Vector buf; - uint64_t flen = fa->get_len(); - buf.resize(fa->get_len() + 1); + uint64_t flen = fa->get_length(); + buf.resize(flen + 1); fa->get_buffer(buf.ptrw(), flen); buf.write[flen] = 0; diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index b3fa17bfb5..ac76506b87 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -233,7 +233,7 @@ Error GLTFDocument::_parse_json(const String &p_path, Ref state) { } Vector array; - array.resize(f->get_len()); + array.resize(f->get_length()); f->get_buffer(array.ptrw(), array.size()); String text; text.parse_utf8((const char *)array.ptr(), array.size()); diff --git a/modules/jpg/image_loader_jpegd.cpp b/modules/jpg/image_loader_jpegd.cpp index 18beff41d8..d237544d66 100644 --- a/modules/jpg/image_loader_jpegd.cpp +++ b/modules/jpg/image_loader_jpegd.cpp @@ -105,7 +105,7 @@ Error jpeg_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p Error ImageLoaderJPG::load_image(Ref p_image, FileAccess *f, bool p_force_linear, float p_scale) { Vector src_image; - uint64_t src_image_len = f->get_len(); + uint64_t src_image_len = f->get_length(); ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT); src_image.resize(src_image_len); diff --git a/modules/mbedtls/crypto_mbedtls.cpp b/modules/mbedtls/crypto_mbedtls.cpp index 4a42e9af0d..c389609984 100644 --- a/modules/mbedtls/crypto_mbedtls.cpp +++ b/modules/mbedtls/crypto_mbedtls.cpp @@ -58,7 +58,7 @@ Error CryptoKeyMbedTLS::load(String p_path, bool p_public_only) { FileAccess *f = FileAccess::open(p_path, FileAccess::READ); ERR_FAIL_COND_V_MSG(!f, ERR_INVALID_PARAMETER, "Cannot open CryptoKeyMbedTLS file '" + p_path + "'."); - uint64_t flen = f->get_len(); + uint64_t flen = f->get_length(); out.resize(flen + 1); f->get_buffer(out.ptrw(), flen); out.write[flen] = 0; // string terminator @@ -146,7 +146,7 @@ Error X509CertificateMbedTLS::load(String p_path) { FileAccess *f = FileAccess::open(p_path, FileAccess::READ); ERR_FAIL_COND_V_MSG(!f, ERR_INVALID_PARAMETER, "Cannot open X509CertificateMbedTLS file '" + p_path + "'."); - uint64_t flen = f->get_len(); + uint64_t flen = f->get_length(); out.resize(flen + 1); f->get_buffer(out.ptrw(), flen); out.write[flen] = 0; // string terminator diff --git a/modules/minimp3/resource_importer_mp3.cpp b/modules/minimp3/resource_importer_mp3.cpp index 96cce49c86..f5137965da 100644 --- a/modules/minimp3/resource_importer_mp3.cpp +++ b/modules/minimp3/resource_importer_mp3.cpp @@ -79,7 +79,7 @@ Error ResourceImporterMP3::import(const String &p_source_file, const String &p_s ERR_FAIL_COND_V(!f, ERR_CANT_OPEN); - uint64_t len = f->get_len(); + uint64_t len = f->get_length(); Vector data; data.resize(len); diff --git a/modules/mono/utils/string_utils.cpp b/modules/mono/utils/string_utils.cpp index 5d53394658..ee68458268 100644 --- a/modules/mono/utils/string_utils.cpp +++ b/modules/mono/utils/string_utils.cpp @@ -170,7 +170,7 @@ Error read_all_file_utf8(const String &p_path, String &r_content) { FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot open file '" + p_path + "'."); - uint64_t len = f->get_len(); + uint64_t len = f->get_length(); sourcef.resize(len + 1); uint8_t *w = sourcef.ptrw(); uint64_t r = f->get_buffer(w, len); diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp index 17380001f5..e3aa630cef 100644 --- a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp +++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp @@ -79,7 +79,7 @@ Error ResourceImporterOGGVorbis::import(const String &p_source_file, const Strin ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, "Cannot open file '" + p_source_file + "'."); - uint64_t len = f->get_len(); + uint64_t len = f->get_length(); Vector data; data.resize(len); diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp index 24fe654946..4911346b96 100644 --- a/modules/svg/image_loader_svg.cpp +++ b/modules/svg/image_loader_svg.cpp @@ -140,7 +140,7 @@ Error ImageLoaderSVG::create_image_from_string(Ref p_image, const char *p } Error ImageLoaderSVG::load_image(Ref p_image, FileAccess *f, bool p_force_linear, float p_scale) { - uint64_t size = f->get_len(); + uint64_t size = f->get_length(); Vector src_image; src_image.resize(size + 1); uint8_t *src_w = src_image.ptrw(); diff --git a/modules/text_server_adv/dynamic_font_adv.cpp b/modules/text_server_adv/dynamic_font_adv.cpp index faeb83f920..c29aac05bb 100644 --- a/modules/text_server_adv/dynamic_font_adv.cpp +++ b/modules/text_server_adv/dynamic_font_adv.cpp @@ -66,7 +66,7 @@ DynamicFontDataAdvanced::DataAtSize *DynamicFontDataAdvanced::get_data_for_size( ERR_FAIL_V_MSG(nullptr, "Cannot open font file '" + font_path + "'."); } - uint64_t len = f->get_len(); + uint64_t len = f->get_length(); font_mem_cache.resize(len); f->get_buffer(font_mem_cache.ptrw(), len); font_mem = font_mem_cache.ptr(); diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index 361852547f..7eff3f8dee 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -181,7 +181,7 @@ bool TextServerAdvanced::load_support_data(const String &p_filename) { UErrorCode err = U_ZERO_ERROR; // ICU data found. - uint64_t len = f->get_len(); + uint64_t len = f->get_length(); icu_data = (uint8_t *)memalloc(len); f->get_buffer(icu_data, len); f->close(); diff --git a/modules/text_server_fb/dynamic_font_fb.cpp b/modules/text_server_fb/dynamic_font_fb.cpp index 406f60b6f5..a261ba8f37 100644 --- a/modules/text_server_fb/dynamic_font_fb.cpp +++ b/modules/text_server_fb/dynamic_font_fb.cpp @@ -65,7 +65,7 @@ DynamicFontDataFallback::DataAtSize *DynamicFontDataFallback::get_data_for_size( ERR_FAIL_V_MSG(nullptr, "Cannot open font file '" + font_path + "'."); } - uint64_t len = f->get_len(); + uint64_t len = f->get_length(); font_mem_cache.resize(len); f->get_buffer(font_mem_cache.ptrw(), len); font_mem = font_mem_cache.ptr(); diff --git a/modules/tga/image_loader_tga.cpp b/modules/tga/image_loader_tga.cpp index 52b92ee930..3cfd4ff36a 100644 --- a/modules/tga/image_loader_tga.cpp +++ b/modules/tga/image_loader_tga.cpp @@ -226,7 +226,7 @@ Error ImageLoaderTGA::convert_to_image(Ref p_image, const uint8_t *p_buff Error ImageLoaderTGA::load_image(Ref p_image, FileAccess *f, bool p_force_linear, float p_scale) { Vector src_image; - uint64_t src_image_len = f->get_len(); + uint64_t src_image_len = f->get_length(); ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT); ERR_FAIL_COND_V(src_image_len < (int64_t)sizeof(tga_header_s), ERR_FILE_CORRUPT); src_image.resize(src_image_len); diff --git a/modules/tinyexr/image_loader_tinyexr.cpp b/modules/tinyexr/image_loader_tinyexr.cpp index cfb75fb93b..eb7a8597e6 100644 --- a/modules/tinyexr/image_loader_tinyexr.cpp +++ b/modules/tinyexr/image_loader_tinyexr.cpp @@ -37,7 +37,7 @@ Error ImageLoaderTinyEXR::load_image(Ref p_image, FileAccess *f, bool p_force_linear, float p_scale) { Vector src_image; - uint64_t src_image_len = f->get_len(); + uint64_t src_image_len = f->get_length(); ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT); src_image.resize(src_image_len); diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp index 15bf9dbf2d..34addb5c9f 100644 --- a/modules/webm/video_stream_webm.cpp +++ b/modules/webm/video_stream_webm.cpp @@ -74,7 +74,7 @@ public: virtual int Length(long long *total, long long *available) { if (file) { - const uint64_t len = file->get_len(); + const uint64_t len = file->get_length(); if (total) { *total = len; } diff --git a/modules/webp/image_loader_webp.cpp b/modules/webp/image_loader_webp.cpp index d7e88d76b1..1f2a456619 100644 --- a/modules/webp/image_loader_webp.cpp +++ b/modules/webp/image_loader_webp.cpp @@ -147,7 +147,7 @@ static Ref _webp_mem_loader_func(const uint8_t *p_png, int p_size) { Error ImageLoaderWEBP::load_image(Ref p_image, FileAccess *f, bool p_force_linear, float p_scale) { Vector src_image; - uint64_t src_image_len = f->get_len(); + uint64_t src_image_len = f->get_length(); ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT); src_image.resize(src_image_len); diff --git a/platform/android/file_access_android.cpp b/platform/android/file_access_android.cpp index 900d4d9b20..90370878b7 100644 --- a/platform/android/file_access_android.cpp +++ b/platform/android/file_access_android.cpp @@ -94,7 +94,7 @@ uint64_t FileAccessAndroid::get_position() const { return pos; } -uint64_t FileAccessAndroid::get_len() const { +uint64_t FileAccessAndroid::get_length() const { return len; } diff --git a/platform/android/file_access_android.h b/platform/android/file_access_android.h index 9b0f85089d..8890e0f645 100644 --- a/platform/android/file_access_android.h +++ b/platform/android/file_access_android.h @@ -54,7 +54,7 @@ public: virtual void seek(uint64_t p_position); ///< seek to a given position virtual void seek_end(int64_t p_position = 0); ///< seek from the end of file virtual uint64_t get_position() const; ///< get position in the file - virtual uint64_t get_len() const; ///< get size of the file + virtual uint64_t get_length() const; ///< get size of the file virtual bool eof_reached() const; ///< reading passed EOF diff --git a/platform/javascript/api/javascript_tools_editor_plugin.cpp b/platform/javascript/api/javascript_tools_editor_plugin.cpp index ac4e6a1256..b35ccd087f 100644 --- a/platform/javascript/api/javascript_tools_editor_plugin.cpp +++ b/platform/javascript/api/javascript_tools_editor_plugin.cpp @@ -72,7 +72,7 @@ void JavaScriptToolsEditorPlugin::_download_zip(Variant p_v) { FileAccess *f = FileAccess::open("/tmp/project.zip", FileAccess::READ); ERR_FAIL_COND_MSG(!f, "Unable to create zip file"); Vector buf; - buf.resize(f->get_len()); + buf.resize(f->get_length()); f->get_buffer(buf.ptrw(), buf.size()); godot_js_os_download_buffer(buf.ptr(), buf.size(), "project.zip", "application/zip"); } @@ -84,7 +84,7 @@ void JavaScriptToolsEditorPlugin::_zip_file(String p_path, String p_base_path, z return; } Vector data; - uint64_t len = f->get_len(); + uint64_t len = f->get_length(); data.resize(len); f->get_buffer(data.ptrw(), len); f->close(); diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index 154f129874..5096285e33 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -547,7 +547,7 @@ Error EditorExportPlatformJavaScript::_build_pwa(const Ref & EditorNode::get_singleton()->show_warning(TTR("Could not read file:") + "\n" + sw_path); return ERR_FILE_CANT_READ; } - sw.resize(f->get_len()); + sw.resize(f->get_length()); f->get_buffer(sw.ptrw(), sw.size()); memdelete(f); f = nullptr; @@ -781,13 +781,13 @@ Error EditorExportPlatformJavaScript::export_project(const Refget_len(); + file_sizes[pck_path.get_file()] = (uint64_t)f->get_length(); memdelete(f); f = nullptr; } f = FileAccess::open(base_path + ".wasm", FileAccess::READ); if (f) { - file_sizes[base_name + ".wasm"] = (uint64_t)f->get_len(); + file_sizes[base_name + ".wasm"] = (uint64_t)f->get_length(); memdelete(f); f = nullptr; } @@ -800,7 +800,7 @@ Error EditorExportPlatformJavaScript::export_project(const Refshow_warning(TTR("Could not read HTML shell:") + "\n" + html_path); return ERR_FILE_CANT_READ; } - html.resize(f->get_len()); + html.resize(f->get_length()); f->get_buffer(html.ptrw(), html.size()); memdelete(f); f = nullptr; diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm index 4c761e77b5..f53b60891f 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/osx/display_server_osx.mm @@ -3479,7 +3479,7 @@ void DisplayServerOSX::set_native_icon(const String &p_filename) { ERR_FAIL_COND(!f); Vector data; - uint64_t len = f->get_len(); + uint64_t len = f->get_length(); data.resize(len); f->get_buffer((uint8_t *)&data.write[0], len); memdelete(f); diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index b2f881a8a8..3a6a5333dd 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -312,7 +312,7 @@ void EditorExportPlatformOSX::_make_icon(const Ref &p_icon, Vectorget_len(); + uint64_t len = f->get_length(); data.resize(data.size() + len + 8); f->get_buffer(&data.write[ofs + 8], len); memdelete(f); @@ -689,8 +689,8 @@ Error EditorExportPlatformOSX::export_project(const Ref &p_p if (iconpath.get_extension() == "icns") { FileAccess *icon = FileAccess::open(iconpath, FileAccess::READ); if (icon) { - data.resize(icon->get_len()); - icon->get_buffer(&data.write[0], icon->get_len()); + data.resize(icon->get_length()); + icon->get_buffer(&data.write[0], icon->get_length()); icon->close(); memdelete(icon); } diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp index 217c119978..f1a857d414 100644 --- a/platform/uwp/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -572,7 +572,7 @@ void AppxPackager::finish() { FileAccess *blockmap_file = FileAccess::open(tmp_blockmap_file_path, FileAccess::READ); Vector blockmap_buffer; - blockmap_buffer.resize(blockmap_file->get_len()); + blockmap_buffer.resize(blockmap_file->get_length()); blockmap_file->get_buffer(blockmap_buffer.ptrw(), blockmap_buffer.size()); @@ -590,7 +590,7 @@ void AppxPackager::finish() { FileAccess *types_file = FileAccess::open(tmp_content_types_file_path, FileAccess::READ); Vector types_buffer; - types_buffer.resize(types_file->get_len()); + types_buffer.resize(types_file->get_length()); types_file->get_buffer(types_buffer.ptrw(), types_buffer.size()); @@ -900,7 +900,7 @@ class EditorExportPlatformUWP : public EditorExportPlatform { ERR_FAIL_V_MSG(data, err_string); } - data.resize(f->get_len()); + data.resize(f->get_length()); f->get_buffer(data.ptrw(), data.size()); f->close(); diff --git a/scene/resources/text_file.cpp b/scene/resources/text_file.cpp index b71909b6bb..564c65adb9 100644 --- a/scene/resources/text_file.cpp +++ b/scene/resources/text_file.cpp @@ -55,7 +55,7 @@ Error TextFile::load_text(const String &p_path) { ERR_FAIL_COND_V_MSG(err, err, "Cannot open TextFile '" + p_path + "'."); - uint64_t len = f->get_len(); + uint64_t len = f->get_length(); sourcef.resize(len + 1); uint8_t *w = sourcef.ptrw(); uint64_t r = f->get_buffer(w, len); diff --git a/tests/test_image.h b/tests/test_image.h index d73717f5b7..99c2a9380d 100644 --- a/tests/test_image.h +++ b/tests/test_image.h @@ -101,8 +101,8 @@ TEST_CASE("[Image] Saving and loading") { Ref image_bmp = memnew(Image()); FileAccessRef f_bmp = FileAccess::open(TestUtils::get_data_path("images/icon.bmp"), FileAccess::READ, &err); PackedByteArray data_bmp; - data_bmp.resize(f_bmp->get_len() + 1); - f_bmp->get_buffer(data_bmp.ptrw(), f_bmp->get_len()); + data_bmp.resize(f_bmp->get_length() + 1); + f_bmp->get_buffer(data_bmp.ptrw(), f_bmp->get_length()); CHECK_MESSAGE( image_bmp->load_bmp_from_buffer(data_bmp) == OK, "The BMP image should load successfully."); @@ -111,8 +111,8 @@ TEST_CASE("[Image] Saving and loading") { Ref image_jpg = memnew(Image()); FileAccessRef f_jpg = FileAccess::open(TestUtils::get_data_path("images/icon.jpg"), FileAccess::READ, &err); PackedByteArray data_jpg; - data_jpg.resize(f_jpg->get_len() + 1); - f_jpg->get_buffer(data_jpg.ptrw(), f_jpg->get_len()); + data_jpg.resize(f_jpg->get_length() + 1); + f_jpg->get_buffer(data_jpg.ptrw(), f_jpg->get_length()); CHECK_MESSAGE( image_jpg->load_jpg_from_buffer(data_jpg) == OK, "The JPG image should load successfully."); @@ -121,8 +121,8 @@ TEST_CASE("[Image] Saving and loading") { Ref image_webp = memnew(Image()); FileAccessRef f_webp = FileAccess::open(TestUtils::get_data_path("images/icon.webp"), FileAccess::READ, &err); PackedByteArray data_webp; - data_webp.resize(f_webp->get_len() + 1); - f_webp->get_buffer(data_webp.ptrw(), f_webp->get_len()); + data_webp.resize(f_webp->get_length() + 1); + f_webp->get_buffer(data_webp.ptrw(), f_webp->get_length()); CHECK_MESSAGE( image_webp->load_webp_from_buffer(data_webp) == OK, "The WEBP image should load successfully."); @@ -131,8 +131,8 @@ TEST_CASE("[Image] Saving and loading") { Ref image_png = memnew(Image()); FileAccessRef f_png = FileAccess::open(TestUtils::get_data_path("images/icon.png"), FileAccess::READ, &err); PackedByteArray data_png; - data_png.resize(f_png->get_len() + 1); - f_png->get_buffer(data_png.ptrw(), f_png->get_len()); + data_png.resize(f_png->get_length() + 1); + f_png->get_buffer(data_png.ptrw(), f_png->get_length()); CHECK_MESSAGE( image_png->load_png_from_buffer(data_png) == OK, "The PNG image should load successfully."); @@ -141,8 +141,8 @@ TEST_CASE("[Image] Saving and loading") { Ref image_tga = memnew(Image()); FileAccessRef f_tga = FileAccess::open(TestUtils::get_data_path("images/icon.tga"), FileAccess::READ, &err); PackedByteArray data_tga; - data_tga.resize(f_tga->get_len() + 1); - f_tga->get_buffer(data_tga.ptrw(), f_tga->get_len()); + data_tga.resize(f_tga->get_length() + 1); + f_tga->get_buffer(data_tga.ptrw(), f_tga->get_length()); CHECK_MESSAGE( image_tga->load_tga_from_buffer(data_tga) == OK, "The TGA image should load successfully."); diff --git a/tests/test_math.cpp b/tests/test_math.cpp index 85cfdf7d2c..88c32713ed 100644 --- a/tests/test_math.cpp +++ b/tests/test_math.cpp @@ -529,8 +529,8 @@ MainLoop *test() { ERR_FAIL_COND_V_MSG(!fa, nullptr, "Could not open file: " + test); Vector buf; - uint64_t flen = fa->get_len(); - buf.resize(fa->get_len() + 1); + uint64_t flen = fa->get_length(); + buf.resize(fa->get_length() + 1); fa->get_buffer(buf.ptrw(), flen); buf.write[flen] = 0; diff --git a/tests/test_pck_packer.h b/tests/test_pck_packer.h index 8e4721b821..06e4e64963 100644 --- a/tests/test_pck_packer.h +++ b/tests/test_pck_packer.h @@ -62,10 +62,10 @@ TEST_CASE("[PCKPacker] Pack an empty PCK file") { err == OK, "The generated empty PCK file should be opened successfully."); CHECK_MESSAGE( - f->get_len() >= 100, + f->get_length() >= 100, "The generated empty PCK file shouldn't be too small (it should have the PCK header)."); CHECK_MESSAGE( - f->get_len() <= 500, + f->get_length() <= 500, "The generated empty PCK file shouldn't be too large."); } @@ -103,10 +103,10 @@ TEST_CASE("[PCKPacker] Pack a PCK file with some files and directories") { err == OK, "The generated non-empty PCK file should be opened successfully."); CHECK_MESSAGE( - f->get_len() >= 25000, + f->get_length() >= 25000, "The generated non-empty PCK file should be large enough to actually hold the contents specified above."); CHECK_MESSAGE( - f->get_len() <= 35000, + f->get_length() <= 35000, "The generated non-empty PCK file shouldn't be too large."); } } // namespace TestPCKPacker