From 35c64c1824d54696e7dc98102ca09c04574ae8a2 Mon Sep 17 00:00:00 2001 From: George Marques Date: Mon, 20 Jun 2016 18:39:37 -0300 Subject: [PATCH] Fix File.get_as_text() to return the whole file It was returning only from the cursor forward. (cherry picked from commit 0f20d8756e6d6842449e4249ba961178b24c72ee) --- core/bind/core_bind.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 6f249a7e645..4605a08bed7 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -1307,7 +1307,12 @@ DVector _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;