Skip to content
Merged
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
17 changes: 17 additions & 0 deletions godot-core/src/tools/gfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<GString> {
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<GString> {
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`.
Expand Down
Loading