#include #include #include #include #include #include #include "7zFile.h" #include "LzmaDec.h" #include "7ZItf.h" #include #include #include #include #include #include #include #include "../common/comm.h" CURLcode Download(const char * url,const char * filename); bool LoadConfig(); void WriteConfig(int32_t version); EgoType Type; int32_t Version; std::string Url; std::string getpath() { char exec_name [BUFSIZ]; readlink ("/proc/self/exe", exec_name, BUFSIZ); int32_t len=strlen(exec_name); for(int i=len;i>=0;i--) { if(exec_name[i]=='/') { exec_name[i]=0; break; } } return std::string(exec_name); } int main() { int32_t version=-1; if(!LoadConfig()) return 0; char szurl[256]; sprintf(szurl,"%s/iego.json",Url.c_str()); if(Download(szurl,"iego.json")==CURLcode::CURLE_OK) { Json::Value root; Json::Reader jsonReader; std::ifstream ifile("./iego.json"); if(jsonReader.parse(ifile,root)) { version=root["car_ver"].asInt(); } if(Version sw(b.newStreamWriter()); //sw.Write(root); std::ofstream ofile; ofile.open("./ego.json",std::ios::out); sw->write(root,&ofile); ofile.close(); } } size_t DownloadCallback(void * pBuffer,size_t nSize,size_t nMemBytes,FILE * fp) { size_t nWrite=fwrite(pBuffer,nSize,nMemBytes,fp); return nWrite; }