2 Copyright (C) 2012 Modelon AB
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the BSD style license.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 FMILIB_License.txt file for more details.
12 You should have received a copy of the FMILIB_License.txt file
13 along with this program. If not, contact Modelon AB <http://www.modelon.com>.
25 #include <JM/jm_types.h>
26 #include <JM/jm_callbacks.h>
27 #include <JM/jm_portability.h>
29 static const char* module = "FMIZIP";
31 jm_status_enu_t fmi_zip_unzip(const char* zip_file_path, const char* output_folder, jm_callbacks* callbacks)
34 Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]
35 -e Extract without pathname (junk paths)
36 -x Extract with pathname
39 -d directory to extract into
40 -o overwrite files without prompting
41 -p extract crypted file using password
44 /* A call to minunz may change the current directory and therefore we must change it back */
45 char cd[FILENAME_MAX];
51 jm_log_verbose(callbacks, module, "Unpacking FMU into %s", output_folder);
56 argv[3]=zip_file_path;
58 argv[5]=output_folder;
61 /* Temporary save the current directory */
62 if (jm_portability_get_current_working_directory(cd, sizeof(cd) / sizeof(char)) == jm_status_error) {
63 jm_log_fatal(callbacks, module, "Could not get Current Directory");
\r
64 return jm_status_error;
68 status = miniunz(argc, (char**)argv);
70 /* Reset the current directory */
71 if (jm_portability_set_current_working_directory(cd) == jm_status_error) {
\r
72 jm_log_warning(callbacks, module, "Could not restore Current Directory after unpacking");
\r
73 return jm_status_warning;
\r
76 /* Return error status */
78 return jm_status_success;
80 jm_log_fatal(callbacks, "FMIZIP", "Unpacking of FMU %s into %s failed", zip_file_path, output_folder);
81 return jm_status_error;