diff --git a/core/io/file_access.compat.inc b/core/io/file_access.compat.inc index f48005da67..d340100fd7 100644 --- a/core/io/file_access.compat.inc +++ b/core/io/file_access.compat.inc @@ -34,6 +34,10 @@ Ref FileAccess::_open_encrypted_bind_compat_98918(const String &p_pa return open_encrypted(p_path, p_mode_flags, p_key, Vector()); } +Ref FileAccess::_create_temp_compat_114053(int p_mode_flags, const String &p_prefix, const String &p_extension, bool p_keep) { + return _create_temp((ModeFlags)p_mode_flags, p_prefix, p_extension, p_keep); +} + void FileAccess::store_8_bind_compat_78289(uint8_t p_dest) { store_8(p_dest); } @@ -100,6 +104,7 @@ String FileAccess::get_as_text_bind_compat_110867(bool p_skip_cr) const { void FileAccess::_bind_compatibility_methods() { ClassDB::bind_compatibility_static_method("FileAccess", D_METHOD("open_encrypted", "path", "mode_flags", "key"), &FileAccess::_open_encrypted_bind_compat_98918); + ClassDB::bind_compatibility_static_method("FileAccess", D_METHOD("create_temp", "mode_flags", "prefix", "extension", "keep"), &FileAccess::_create_temp_compat_114053, DEFVAL(""), DEFVAL(""), DEFVAL(false)); ClassDB::bind_compatibility_method(D_METHOD("store_8", "value"), &FileAccess::store_8_bind_compat_78289); ClassDB::bind_compatibility_method(D_METHOD("store_16", "value"), &FileAccess::store_16_bind_compat_78289); diff --git a/core/io/file_access.cpp b/core/io/file_access.cpp index b869af3717..caae8ee026 100644 --- a/core/io/file_access.cpp +++ b/core/io/file_access.cpp @@ -79,7 +79,7 @@ Ref FileAccess::create_for_path(const String &p_path) { return ret; } -Ref FileAccess::create_temp(int p_mode_flags, const String &p_prefix, const String &p_extension, bool p_keep, Error *r_error) { +Ref FileAccess::create_temp(ModeFlags p_mode_flags, const String &p_prefix, const String &p_extension, bool p_keep, Error *r_error) { const String ERROR_COMMON_PREFIX = "Error while creating temporary file"; if (!p_prefix.is_empty() && !p_prefix.is_valid_filename()) { @@ -136,7 +136,7 @@ Ref FileAccess::create_temp(int p_mode_flags, const String &p_prefix return ret; } -Ref FileAccess::_create_temp(int p_mode_flags, const String &p_prefix, const String &p_extension, bool p_keep) { +Ref FileAccess::_create_temp(ModeFlags p_mode_flags, const String &p_prefix, const String &p_extension, bool p_keep) { return create_temp(p_mode_flags, p_prefix, p_extension, p_keep, &last_file_open_error); } diff --git a/core/io/file_access.h b/core/io/file_access.h index 4b7fa787a5..77fbc99925 100644 --- a/core/io/file_access.h +++ b/core/io/file_access.h @@ -122,6 +122,7 @@ protected: #ifndef DISABLE_DEPRECATED static Ref _open_encrypted_bind_compat_98918(const String &p_path, ModeFlags p_mode_flags, const Vector &p_key); + static Ref _create_temp_compat_114053(int p_mode_flags, const String &p_prefix = "", const String &p_extension = "", bool p_keep = false); void store_8_bind_compat_78289(uint8_t p_dest); void store_16_bind_compat_78289(uint16_t p_dest); @@ -160,7 +161,7 @@ private: String _temp_path; void _delete_temp(); - static Ref _create_temp(int p_mode_flags, const String &p_prefix = "", const String &p_extension = "", bool p_keep = false); + static Ref _create_temp(ModeFlags p_mode_flags, const String &p_prefix = "", const String &p_extension = "", bool p_keep = false); public: static void set_file_close_fail_notify_callback(FileCloseFailNotify p_cbk) { close_fail_notify = p_cbk; } @@ -241,7 +242,7 @@ public: static Ref create(AccessType p_access); /// Create a file access (for the current platform) this is the only portable way of accessing files. static Ref create_for_path(const String &p_path); static Ref open(const String &p_path, int p_mode_flags, Error *r_error = nullptr); /// Create a file access (for the current platform) this is the only portable way of accessing files. - static Ref create_temp(int p_mode_flags, const String &p_prefix = "", const String &p_extension = "", bool p_keep = false, Error *r_error = nullptr); + static Ref create_temp(ModeFlags p_mode_flags, const String &p_prefix = "", const String &p_extension = "", bool p_keep = false, Error *r_error = nullptr); static Ref open_encrypted(const String &p_path, ModeFlags p_mode_flags, const Vector &p_key, const Vector &p_iv = Vector()); static Ref open_encrypted_pass(const String &p_path, ModeFlags p_mode_flags, const String &p_pass); diff --git a/doc/classes/FileAccess.xml b/doc/classes/FileAccess.xml index 087ccd9a34..cdfdb36511 100644 --- a/doc/classes/FileAccess.xml +++ b/doc/classes/FileAccess.xml @@ -53,7 +53,7 @@ - + diff --git a/misc/extension_api_validation/4.5-stable/GH-114053.txt b/misc/extension_api_validation/4.5-stable/GH-114053.txt new file mode 100644 index 0000000000..d4181a3f61 --- /dev/null +++ b/misc/extension_api_validation/4.5-stable/GH-114053.txt @@ -0,0 +1,7 @@ +GH-114053 +--------- +Validate extension JSON: Error: Field 'classes/FileAccess/methods/create_temp/arguments': meta was removed. +Validate extension JSON: Error: Field 'classes/FileAccess/methods/create_temp/arguments/0': type changed value in new API, from "int" to "enum::FileAccess.ModeFlags". + +The argument was supposed to use this enum instead of an untyped int. +A compatibility method has been registered.