Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling for FileAccess.get_file_as_* #82595

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/io/file_access.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ class FileAccess : public RefCounted {
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) {
Expand Down
2 changes: 2 additions & 0 deletions doc/classes/FileAccess.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,15 @@
<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">
<return type="String" />
<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">
Expand Down
Loading