153{
154 if (path.find(".terr3dpack") == std::string::npos)
155 {
156 path = path + ".terr3dpack";
157 }
158
159 std::string uid = GenerateId(64);
160 MkDir(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "temp"
161 PATH_SEPARATOR "pcache_" + uid);
162 zip_extract(path.c_str(), (GetExecutableDir() + PATH_SEPARATOR "Data"
163 PATH_SEPARATOR "temp" PATH_SEPARATOR "pcache_" + uid).c_str(),
164 [](const char *filename, void *arg)
165 {
166 return 1;
167 }, (void *)0);
168
169 if (FileExists(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "temp" PATH_SEPARATOR "pcache_" + uid + PATH_SEPARATOR "project.terr3d", true))
170 {
171 bool tmp = false;
172 std::string sdata = ReadShaderSourceFile(GetExecutableDir() +
173 PATH_SEPARATOR "Data" PATH_SEPARATOR "temp" PATH_SEPARATOR
174 "pcache_" + uid + PATH_SEPARATOR "project.terr3d", &tmp);
175
176 if (sdata.size() <= 0)
177 {
178 Log("Emppty Project File!");
179 return;
180 }
181
183
184 try
185 {
187 }
188
189 catch (...)
190 {
191 Log("Failed to Parse Project file!");
192 return;
193 }
194
195 std::string projId = data["projectID"];
196 zip_extract(path.c_str(), (GetExecutableDir() + PATH_SEPARATOR "Data"
197 PATH_SEPARATOR "cache" PATH_SEPARATOR "project_data"
198 PATH_SEPARATOR "project_" + projId).c_str(), [](const char
199 *filename, void *arg)
200 {
201 Log(std::string("Extracted ") + filename);
202 return 1;
203 }, (void *)0);
204 std::string oriDir = path.substr(0, path.rfind(PATH_SEPARATOR));
205 std::string oriName = path.substr(path.rfind(PATH_SEPARATOR) + 1);
206 CopyFileData((GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR
207 "cache" PATH_SEPARATOR "project_data" PATH_SEPARATOR
208 "project_" + projId + PATH_SEPARATOR
209 "project.terr3d").c_str(), oriDir + PATH_SEPARATOR +
210 oriName + ".terr3d");
211 LoadFile(oriDir + PATH_SEPARATOR + oriName + ".terr3d");
212 }
213
214 else
215 {
216 Log("Not a valid terr3dpack file!");
217 }
218}
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse(InputType &&i, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
deserialize from a compatible input
a class to store JSON values