aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Marques2016-06-20 18:39:37 -0300
committerRémi Verschelde2016-06-25 01:42:00 +0200
commit35c64c1824d54696e7dc98102ca09c04574ae8a2 (patch)
tree7c2cc26d2e76a7d440b7a190dd163e033ec4720d
parentaa581a067dde0f64d8f3a594bfcae01e563ca74b (diff)
downloadgodot-35c64c1824d54696e7dc98102ca09c04574ae8a2.tar.gz
godot-35c64c1824d54696e7dc98102ca09c04574ae8a2.tar.zst
godot-35c64c1824d54696e7dc98102ca09c04574ae8a2.zip
Fix File.get_as_text() to return the whole file
It was returning only from the cursor forward. (cherry picked from commit 0f20d8756e6d6842449e4249ba961178b24c72ee)
-rw-r--r--core/bind/core_bind.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 6f249a7e6..4605a08be 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -1307,7 +1307,12 @@ DVector<uint8_t> _File::get_buffer(int p_length) const{
String _File::get_as_text() const {
+ ERR_FAIL_COND_V(!f, String());
+
String text;
+ size_t original_pos = f->get_pos();
+ f->seek(0);
+
String l = get_line();
while(!eof_reached()) {
text+=l+"\n";
@@ -1315,6 +1320,8 @@ String _File::get_as_text() const {
}
text+=l;
+ f->seek(original_pos);
+
return text;