diff --git a/a8/stringlist.cc b/a8/stringlist.cc index e290781..14f7459 100644 --- a/a8/stringlist.cc +++ b/a8/stringlist.cc @@ -69,6 +69,11 @@ namespace a8 } p2++; } + #if 0 + if (p2 > p1) { + Add(p2 > p1 ? std::string(p1, p2 - p1) : ""); + } + #endif } std::string StringList::Text() diff --git a/a8/xobject.cc b/a8/xobject.cc index cc18a80..1341313 100644 --- a/a8/xobject.cc +++ b/a8/xobject.cc @@ -300,9 +300,29 @@ namespace a8 bool XObject::ReadFromJsonFile(const std::string& filename) { - a8::StringList sl; - sl.LoadFromFile(filename.c_str()); - return ReadFromJsonString(sl.Text()); + std::string json_data; + { + FILE *fp = fopen(filename.c_str(), "rb"); + if (!fp) { + return false; + } + fseek(fp, 0, SEEK_END); + int fileSize = ftell(fp); + if(fileSize){ + char *p = (char*)malloc(fileSize + 1); + if(p){ + *(p + fileSize) = '\0'; + fseek(fp, 0, SEEK_SET); + fread(p, 1, fileSize, fp); + if (fileSize > 0) { + json_data.append(p, fileSize); + } + free(p); + } + } + fclose(fp); + } + return ReadFromJsonString(json_data); } bool XObject::ReadFromJsonString(const std::string& json_data)