diff --git a/godot-core/src/tools/gfile.rs b/godot-core/src/tools/gfile.rs index 5b97a5945..f4fb13130 100644 --- a/godot-core/src/tools/gfile.rs +++ b/godot-core/src/tools/gfile.rs @@ -332,13 +332,30 @@ impl GFile { /// /// Underlying Godot method: /// [`FileAccess::get_as_text`](https://docs.godotengine.org/en/stable/classes/class_fileaccess.html#class-fileaccess-method-get-as-text). + // For Godot versions before `skip_cr` has been removed, see: https://github.com/godotengine/godot/pull/110867. #[doc(alias = "get_as_text")] + #[cfg(before_api = "4.6")] pub fn read_as_gstring_entire(&mut self, skip_cr: bool) -> std::io::Result { let val = self.fa.get_as_text_ex().skip_cr(skip_cr).done(); self.check_error()?; Ok(val) } + /// Reads the whole file as UTF-8 [`GString`]. + /// + /// To retrieve the file as [`String`] instead, use the [`Read`] trait method + /// [`read_to_string()`](https://doc.rust-lang.org/std/io/trait.Read.html#method.read_to_string). + /// + /// Underlying Godot method: + /// [`FileAccess::get_as_text`](https://docs.godotengine.org/en/stable/classes/class_fileaccess.html#class-fileaccess-method-get-as-text). + #[doc(alias = "get_as_text")] + #[cfg(since_api = "4.6")] + pub fn read_as_gstring_entire(&mut self) -> std::io::Result { + let val = self.fa.get_as_text(); + self.check_error()?; + Ok(val) + } + /// Reads the next line of the file in delimiter-separated file. /// /// For reading traditional `CSV` format, provide comma (`','`) as `delim`.