@@ -141,12 +141,10 @@ oms_status_enu_t oms::Scope::exportModel(const oms::ComRef& cref, const std::str
141141 return model->exportToFile (filename);
142142}
143143
144- oms_status_enu_t oms::Scope::miniunz (const std::string& filename, const std::string& extractdir, bool systemStructure )
144+ oms_status_enu_t oms::Scope::miniunz (const std::string& filename, const std::string& extractdir)
145145{
146- // This function is used to extract (1) complete SSP/FMU files or to extract
147- // (2) the SystemStructure.ssd from an SSP file:
148- // (1) miniunz -xo <filename> -d <extractdir>
149- // (2) miniunz -xo <filename> SystemStructure.ssd -d <extractdir>
146+ // This function is used to extract complete SSP/FMU files:
147+ // miniunz -xo <filename> -d <extractdir>
150148
151149 // Usage: miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]
152150 // -e Extract without pathname (junk paths)
@@ -159,14 +157,12 @@ oms_status_enu_t oms::Scope::miniunz(const std::string& filename, const std::str
159157
160158 std::string cd = Scope::GetInstance ().getWorkingDirectory ();
161159
162- int argc = systemStructure ? 6 : 5 ;
160+ int argc = 5 ;
163161 char **argv = new char *[argc];
164162 int i=0 ;
165163 argv[i++] = (char *)" miniunz" ;
166164 argv[i++] = (char *)" -xo" ;
167165 argv[i++] = (char *)filename.c_str ();
168- if (systemStructure)
169- argv[i++] = (char *)" SystemStructure.ssd" ;
170166 argv[i++] = (char *)" -d" ;
171167 argv[i++] = (char *)extractdir.c_str ();
172168 int status = ::miniunz (argc, argv);
@@ -195,13 +191,17 @@ oms_status_enu_t oms::Scope::importModel(const std::string& filename, char** _cr
195191 if (extension != " .ssp" )
196192 return logError (" filename extension must be \" .ssp\" ; no other formats are supported" );
197193
198- // extract SystemStructure.ssd to temp
199- filesystem::path temp_root ( getTempDirectory () );
200- if (oms_status_ok != oms::Scope::miniunz (filename, temp_root. string (), true ) )
201- return logError (" failed to extract \" SystemStructure.ssd\" from \" " + filename + " \" " );
194+ // extract SystemStructure.ssd to memory
195+ const char * systemStructure = :: miniunz_onefile_to_memory (filename. c_str (), " SystemStructure.ssd " );
196+ if (!systemStructure )
197+ return logError (" failed to extract \" SystemStructure.ssd\" from \" " + std::string ( filename) + " \" " );
202198
203199 Snapshot snapshot;
204- snapshot.importResourceFile (" SystemStructure.ssd" , temp_root);
200+ oms_status_enu_t status = snapshot.importResourceMemory (" SystemStructure.ssd" , systemStructure);
201+ ::miniunz_free (systemStructure);
202+ if (oms_status_ok != status)
203+ return logError (" Failed to import" );
204+
205205 const pugi::xml_node node = snapshot.getResourceNode (" SystemStructure.ssd" );
206206 if (!node)
207207 return logError (" failed to load \" SystemStructure.ssd\" " );
@@ -217,7 +217,7 @@ oms_status_enu_t oms::Scope::importModel(const std::string& filename, char** _cr
217217 logWarning (" Unknown SSD version: " + ssdVersion);
218218
219219 // extract the ssp file
220- oms::Scope::miniunz (filename, model->getTempDirectory (), false );
220+ oms::Scope::miniunz (filename, model->getTempDirectory ());
221221
222222 std::string cd = Scope::GetInstance ().getWorkingDirectory ();
223223 Scope::GetInstance ().setWorkingDirectory (model->getTempDirectory ());
@@ -233,7 +233,7 @@ oms_status_enu_t oms::Scope::importModel(const std::string& filename, char** _cr
233233
234234 // snapshot.debugPrintAll();
235235
236- oms_status_enu_t status = model->importFromSnapshot (snapshot);
236+ status = model->importFromSnapshot (snapshot);
237237 model->copyResources (old_copyResources);
238238
239239 Scope::GetInstance ().setWorkingDirectory (cd);
0 commit comments