| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "core/idatasink.h" |
| 7 | #include <filesystem> |
| 8 | #include <string> |
| 9 | #include <utility> |
| 10 | #include <vector> |
| 11 | |
| 12 | class ZipDataSink final |
| 13 | : public IDataSink<std::vector<std::pair<std::string, std::vector<char>>>> |
| 14 | { |
| 15 | public: |
| 16 | ZipDataSink(std::filesystem::path const &path) noexcept; |
| 17 | ~ZipDataSink(); |
| 18 | |
| 19 | std::string sink() const override; |
| 20 | bool write(std::vector<std::pair<std::string, std::vector<char>>> const &data) |
| 21 | override; |
| 22 | |
| 23 | private: |
| 24 | void backupFile() const; |
| 25 | void removeBackupFile() const; |
| 26 | void restorePreWriteFileState() const; |
| 27 | |
| 28 | std::filesystem::path const path_; |
| 29 | }; |