diff options
Diffstat (limited to 'core/io')
-rw-r--r-- | core/io/file_access_memory.cpp | 2 | ||||
-rw-r--r-- | core/io/resource_loader.cpp | 1 | ||||
-rw-r--r-- | core/io/translation_loader_po.cpp | 25 | ||||
-rw-r--r-- | core/io/translation_loader_po.h | 4 |
4 files changed, 23 insertions, 9 deletions
diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index 2cc52a9e2d..7db3499505 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -135,7 +135,7 @@ size_t FileAccessMemory::get_len() const { bool FileAccessMemory::eof_reached() const { - return pos >= length; + return pos > length; } uint8_t FileAccessMemory::get_8() const { diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index abb1082256..b547dc0e85 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -243,6 +243,7 @@ Ref<ResourceImportMetadata> ResourceLoader::load_import_metadata(const String &p break; } + return ret; } diff --git a/core/io/translation_loader_po.cpp b/core/io/translation_loader_po.cpp index fe101a8676..4ddb276a27 100644 --- a/core/io/translation_loader_po.cpp +++ b/core/io/translation_loader_po.cpp @@ -30,13 +30,8 @@ #include "os/file_access.h" #include "translation.h" -RES TranslationLoaderPO::load(const String &p_path, const String& p_original_path, Error *r_error) { - if (r_error) - *r_error=ERR_CANT_OPEN; - - FileAccess *f=FileAccess::open(p_path,FileAccess::READ); - ERR_FAIL_COND_V(!f,RES()); +RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const String &p_path) { String l = f->get_line(); @@ -52,6 +47,8 @@ RES TranslationLoaderPO::load(const String &p_path, const String& p_original_pat String msg_id; String msg_str; String config; + int msg_line=0; + if (r_error) *r_error=ERR_FILE_CORRUPT; @@ -87,7 +84,7 @@ RES TranslationLoaderPO::load(const String &p_path, const String& p_original_pat if (status==STATUS_READING_ID) { memdelete(f); - ERR_EXPLAIN(p_path+":"+itos(line)+" nexpected 'msgid', was expecting 'msgstr' while parsing: "); + ERR_EXPLAIN(p_path+":"+itos(line)+" Unexpected 'msgid', was expecting 'msgstr' while parsing: "); ERR_FAIL_V(RES()); } @@ -100,6 +97,7 @@ RES TranslationLoaderPO::load(const String &p_path, const String& p_original_pat status=STATUS_READING_ID; msg_id=""; msg_str=""; + msg_line=line; } if (l.begins_with("msgstr")) { @@ -113,6 +111,7 @@ RES TranslationLoaderPO::load(const String &p_path, const String& p_original_pat l=l.substr(6,l.length()).strip_edges(); status=STATUS_READING_STRING; + msg_line=line; } if (l=="" || l.begins_with("#")) { @@ -183,6 +182,18 @@ RES TranslationLoaderPO::load(const String &p_path, const String& p_original_pat *r_error=OK; return translation; +} + +RES TranslationLoaderPO::load(const String &p_path, const String& p_original_path, Error *r_error) { + + if (r_error) + *r_error=ERR_CANT_OPEN; + + FileAccess *f=FileAccess::open(p_path,FileAccess::READ); + ERR_FAIL_COND_V(!f,RES()); + + + return load_translation(f,r_error); } diff --git a/core/io/translation_loader_po.h b/core/io/translation_loader_po.h index a569674d80..b0c4e42682 100644 --- a/core/io/translation_loader_po.h +++ b/core/io/translation_loader_po.h @@ -30,10 +30,12 @@ #define TRANSLATION_LOADER_PO_H #include "io/resource_loader.h" - +#include "translation.h" +#include "os/file_access.h" class TranslationLoaderPO : public ResourceFormatLoader { public: + static RES load_translation(FileAccess *f, Error *r_error,const String& p_path=String()); virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String& p_type) const; |