Skip to content

Commit

Permalink
expose unzipper
Browse files Browse the repository at this point in the history
  • Loading branch information
markaren committed Oct 27, 2024
1 parent 71d3004 commit 38799be
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
14 changes: 14 additions & 0 deletions include/fmi4cpp/tools/unzipper.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

#ifndef FMI4CPP_UNZIPPER_HPP
#define FMI4CPP_UNZIPPER_HPP

#include <filesystem>

namespace fmi4cpp
{

bool unzip(const std::filesystem::path& zip_file, const std::filesystem::path& tmp_path);

} // namespace fmi4cpp

#endif // FMI4CPP_UNZIPPER_HPP
5 changes: 4 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ set(publicHeaders
"fmi4cpp/fmi2/xml/scalar_variable.hpp"
"fmi4cpp/fmi2/xml/typed_scalar_variable.hpp"

"fmi4cpp/tools/unzipper.hpp"

)

set(privateHeaders
Expand All @@ -58,7 +60,6 @@ set(privateHeaders

"fmi4cpp/tools/simple_id.hpp"
"fmi4cpp/tools/os_util.hpp"
"fmi4cpp/tools/unzipper.hpp"

)

Expand All @@ -82,6 +83,8 @@ set(sources
"fmi4cpp/fmi2/xml/model_variables.cpp"
"fmi4cpp/fmi2/xml/scalar_variable.cpp"

"fmi4cpp/tools/unzipper.cpp"

)

set(publicHeadersFull)
Expand Down
15 changes: 3 additions & 12 deletions src/fmi4cpp/tools/unzipper.hpp → src/fmi4cpp/tools/unzipper.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@

#ifndef FMI4CPP_UNZIPPER_HPP
#define FMI4CPP_UNZIPPER_HPP
#include "fmi4cpp/tools/unzipper.hpp"

#include <zip.h>

#include <filesystem>
#include <fstream>
#include <string>

namespace fmi4cpp
{

inline bool unzip(const std::filesystem::path& zip_file, const std::filesystem::path& tmp_path)
bool fmi4cpp::unzip(const std::filesystem::path& zip_file, const std::filesystem::path& tmp_path)
{
int* err = nullptr;
zip* za = zip_open(absolute(zip_file).string().c_str(), 0, err);
Expand All @@ -24,7 +19,7 @@ inline bool unzip(const std::filesystem::path& zip_file, const std::filesystem::
struct zip_stat sb{};
// clang-format on

const int bufferSize = 1000;
constexpr int bufferSize = 1000;
std::vector<char> contents(bufferSize);

Check failure on line 23 in src/fmi4cpp/tools/unzipper.cpp

View workflow job for this annotation

GitHub Actions / vcpkg-on-linux (ubuntu-22.04, 11)

‘vector’ is not a member of ‘std’

Check failure on line 23 in src/fmi4cpp/tools/unzipper.cpp

View workflow job for this annotation

GitHub Actions / vcpkg-on-linux (ubuntu-22.04, 11)

expected primary-expression before ‘char’
zip_int64_t sum;
zip_int64_t len;
Expand Down Expand Up @@ -63,7 +58,3 @@ inline bool unzip(const std::filesystem::path& zip_file, const std::filesystem::

return true;
}

} // namespace fmi4cpp

#endif // FMI4CPP_UNZIPPER_HPP

0 comments on commit 38799be

Please sign in to comment.