diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-10-11 22:37:54 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-10-11 22:37:54 +0200 |
commit | 587f084200adacd58d6dba53a88b0324b35e78b4 (patch) | |
tree | 699a6f110a922d053e517312021b25a33ef33817 | |
parent | 357a57b828b79537c8c8c5771cbe6fe19a48af0a (diff) | |
parent | bf3f6e3b55076f11b46c92fee93247cb69a6db98 (diff) | |
download | redot-engine-587f084200adacd58d6dba53a88b0324b35e78b4.tar.gz |
Merge pull request #82595 from paulloz/fix-fileaccess-error-handling
Error handling for `FileAccess.get_file_as_*`
-rw-r--r-- | core/io/file_access.h | 4 | ||||
-rw-r--r-- | doc/classes/FileAccess.xml | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/core/io/file_access.h b/core/io/file_access.h index 7b9e66bb83..7d346ca2f4 100644 --- a/core/io/file_access.h +++ b/core/io/file_access.h @@ -223,8 +223,8 @@ public: static Vector<uint8_t> get_file_as_bytes(const String &p_path, Error *r_error = nullptr); static String get_file_as_string(const String &p_path, Error *r_error = nullptr); - static PackedByteArray _get_file_as_bytes(const String &p_path) { return get_file_as_bytes(p_path); } - static String _get_file_as_string(const String &p_path) { return get_file_as_string(p_path); }; + static PackedByteArray _get_file_as_bytes(const String &p_path) { return get_file_as_bytes(p_path, &last_file_open_error); } + static String _get_file_as_string(const String &p_path) { return get_file_as_string(p_path, &last_file_open_error); } template <class T> static void make_default(AccessType p_access) { diff --git a/doc/classes/FileAccess.xml b/doc/classes/FileAccess.xml index 42528dc287..d1b20a3890 100644 --- a/doc/classes/FileAccess.xml +++ b/doc/classes/FileAccess.xml @@ -155,6 +155,7 @@ <param index="0" name="path" type="String" /> <description> Returns the whole [param path] file contents as a [PackedByteArray] without any decoding. + Returns an empty [PackedByteArray] if an error occurred while opening the file. You can use [method get_open_error] to check the error that occurred. </description> </method> <method name="get_file_as_string" qualifiers="static"> @@ -162,6 +163,7 @@ <param index="0" name="path" type="String" /> <description> Returns the whole [param path] file contents as a [String]. Text is interpreted as being UTF-8 encoded. + Returns an empty [String] if an error occurred while opening the file. You can use [method get_open_error] to check the error that occurred. </description> </method> <method name="get_float" qualifiers="const"> |