summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2019-03-03 18:00:12 -0300
committerGitHub <noreply@github.com>2019-03-03 18:00:12 -0300
commita9fe834a8e962a7b9e15e5dc218af4b857b47da4 (patch)
tree238cbd6ea6d97aec228d4af9ae1ce00466767e89 /core
parent8b4c4d9b2fbfa39e71bc1e4f4fcdd5377a9396e4 (diff)
parentbda60bfa29a43315755bac92dc15fb0a1a30c22e (diff)
Merge pull request #26547 from vnen/gdscript-dependency-parse
Add a parse mode for GDScript which doesn't load dependencies
Diffstat (limited to 'core')
-rw-r--r--core/os/file_access.cpp17
-rw-r--r--core/os/file_access.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index d1f8236898..39d9f45bd7 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -409,6 +409,23 @@ int FileAccess::get_buffer(uint8_t *p_dst, int p_length) const {
return i;
}
+String FileAccess::get_as_utf8_string() const {
+ PoolVector<uint8_t> sourcef;
+ int len = get_len();
+ sourcef.resize(len + 1);
+
+ PoolVector<uint8_t>::Write w = sourcef.write();
+ int r = get_buffer(w.ptr(), len);
+ ERR_FAIL_COND_V(r != len, String());
+ w[len] = 0;
+
+ String s;
+ if (s.parse_utf8((const char *)w.ptr())) {
+ return String();
+ }
+ return s;
+}
+
void FileAccess::store_16(uint16_t p_dest) {
uint8_t a, b;
diff --git a/core/os/file_access.h b/core/os/file_access.h
index 7bfbf6e7f0..c65b75369c 100644
--- a/core/os/file_access.h
+++ b/core/os/file_access.h
@@ -113,6 +113,7 @@ public:
virtual String get_line() const;
virtual String get_token() const;
virtual Vector<String> get_csv_line(const String &p_delim = ",") const;
+ virtual String get_as_utf8_string() const;
/**< use this for files WRITTEN in _big_ endian machines (ie, amiga/mac)
* It's not about the current CPU type but file formats.