Fix File.get_as_text() to return the whole file
It was returning only from the cursor forward.
(cherry picked from commit 0f20d8756e
)
This commit is contained in:
parent
aa581a067d
commit
35c64c1824
|
@ -1307,7 +1307,12 @@ DVector<uint8_t> _File::get_buffer(int p_length) const{
|
||||||
|
|
||||||
String _File::get_as_text() const {
|
String _File::get_as_text() const {
|
||||||
|
|
||||||
|
ERR_FAIL_COND_V(!f, String());
|
||||||
|
|
||||||
String text;
|
String text;
|
||||||
|
size_t original_pos = f->get_pos();
|
||||||
|
f->seek(0);
|
||||||
|
|
||||||
String l = get_line();
|
String l = get_line();
|
||||||
while(!eof_reached()) {
|
while(!eof_reached()) {
|
||||||
text+=l+"\n";
|
text+=l+"\n";
|
||||||
|
@ -1315,6 +1320,8 @@ String _File::get_as_text() const {
|
||||||
}
|
}
|
||||||
text+=l;
|
text+=l;
|
||||||
|
|
||||||
|
f->seek(original_pos);
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue