1
This commit is contained in:
parent
64b7d5ad26
commit
ec92ae9234
@ -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()
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user