浏览代码

Fix File.get_as_text() to return the whole file

It was returning only from the cursor forward.
George Marques 9 年之前
父节点
当前提交
0f20d8756e
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      core/bind/core_bind.cpp

+ 7 - 0
core/bind/core_bind.cpp

@@ -1566,7 +1566,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";
@@ -1574,6 +1579,8 @@ String _File::get_as_text() const {
 	}
 	text+=l;
 
+	f->seek(original_pos);
+
 	return text;