22#ifndef FMI4CPP_UNZIPPER_HPP
33#define FMI4CPP_UNZIPPER_HPP
44
5- #include < fmi4cpp/fs_portability.hpp>
6-
75#include < zip.h>
86
7+ #include < filesystem>
98#include < fstream>
10- #include < iostream>
11- #include < sstream>
129#include < string>
1310
14- namespace
11+ namespace fmi4cpp
1512{
1613
17- bool unzip (const fmi4cpp::fs ::path& zip_file, const fmi4cpp::fs ::path& tmp_path)
14+ inline bool unzip (const std::filesystem ::path& zip_file, const std::filesystem ::path& tmp_path)
1815{
1916 int * err = nullptr ;
2017 zip* za = zip_open (absolute (zip_file).string ().c_str (), 0 , err);
@@ -34,13 +31,13 @@ bool unzip(const fmi4cpp::fs::path& zip_file, const fmi4cpp::fs::path& tmp_path)
3431 for (int i = 0 ; i < zip_get_num_entries (za, 0 ); i++) {
3532 if (zip_stat_index (za, i, 0 , &sb) == 0 ) {
3633
37- const fmi4cpp::fs ::path newFile = tmp_path / sb.name ;
34+ const std::filesystem ::path newFile = tmp_path / sb.name ;
3835
3936 if (sb.size == 0 ) {
40- fmi4cpp::fs:: create_directories (newFile);
37+ create_directories (newFile);
4138 } else {
4239 const auto containingDirectory = newFile.parent_path ();
43- if (!fmi4cpp::fs:: exists (containingDirectory) && !fmi4cpp::fs:: create_directories (containingDirectory)) {
40+ if (!exists (containingDirectory) && !create_directories (containingDirectory)) {
4441 return false ;
4542 }
4643 zf = zip_fopen_index (za, i, 0 );
@@ -67,6 +64,6 @@ bool unzip(const fmi4cpp::fs::path& zip_file, const fmi4cpp::fs::path& tmp_path)
6764 return true ;
6865}
6966
70- } // namespace
67+ } // namespace fmi4cpp
7168
7269#endif // FMI4CPP_UNZIPPER_HPP
0 commit comments