18 const auto filepath = std::filesystem::path(file);
19 const auto parent_path = filepath.parent_path();
20 const auto zip_path = parent_path /
"old_logs.zip";
22 struct zip_t* zip =
nullptr;
23 if (std::filesystem::exists(zip_path))
25 zip = zip_open(zip_path.string().c_str(), ZIP_DEFAULT_COMPRESSION_LEVEL,
'a');
29 zip = zip_open(zip_path.string().c_str(), ZIP_DEFAULT_COMPRESSION_LEVEL,
'w');
32 for (
const auto& path : std::filesystem::recursive_directory_iterator(parent_path))
34 const auto entry_path = std::filesystem::path(path);
35 if (std::filesystem::is_regular_file(entry_path) && entry_path.extension() ==
".log" && entry_path.stem() != filepath.stem())
37 zip_entry_open(zip, entry_path.filename().string().c_str());
38 zip_entry_fwrite(zip, entry_path.string().c_str());
41 std::filesystem::remove(entry_path);