Correlation 4.10.0
An Analysis Tool for Liquids and for Amorphous Solids
Loading...
Searching...
No Matches
ZipArchiveWriter.hpp
Go to the documentation of this file.
1
8
9#pragma once
10
11#include <cstddef>
12#include <expected>
13#include <filesystem>
14#include <memory>
15#include <span>
16#include <string>
17#include <string_view>
18
20
26public:
29
32
35
41 std::expected<void, std::string> open(const std::filesystem::path &archive_path);
42
49 std::expected<void, std::string> addFileFromMemory(std::string_view entry_name,
50 std::span<const std::byte> data);
51
58 std::expected<void, std::string> addFileFromString(std::string_view entry_name,
59 std::string_view content);
60
67 std::expected<void, std::string> addFileFromDisk(std::string_view entry_name,
68 const std::filesystem::path &source_path);
69
74 std::expected<void, std::string> finalize();
75
79 [[nodiscard]] bool isOpen() const noexcept;
80
81private:
82 struct Impl;
83 std::unique_ptr<Impl> impl_;
84};
85
86} // namespace correlation::utils
std::expected< void, std::string > open(const std::filesystem::path &archive_path)
Opens a new ZIP archive for writing on disk.
Definition ZipArchiveWriter.cpp:49
std::expected< void, std::string > finalize()
Finalizes and closes the archive.
Definition ZipArchiveWriter.cpp:123
std::expected< void, std::string > addFileFromMemory(std::string_view entry_name, std::span< const std::byte > data)
Adds a file to the archive from an in-memory buffer.
Definition ZipArchiveWriter.cpp:71
std::expected< void, std::string > addFileFromString(std::string_view entry_name, std::string_view content)
Adds a text file to the archive from a string or string_view.
Definition ZipArchiveWriter.cpp:90
std::expected< void, std::string > addFileFromDisk(std::string_view entry_name, const std::filesystem::path &source_path)
Adds a file from the local filesystem to the archive.
Definition ZipArchiveWriter.cpp:98
ZipArchiveWriter(ZipArchiveWriter &&other) noexcept
bool isOpen() const noexcept
Checks if an archive is currently open.
Definition ZipArchiveWriter.cpp:47
ZipArchiveWriter & operator=(ZipArchiveWriter &&other) noexcept
ZipArchiveWriter & operator=(const ZipArchiveWriter &)=delete
ZipArchiveWriter()
Definition ZipArchiveWriter.cpp:39
std::unique_ptr< Impl > impl_
Definition ZipArchiveWriter.hpp:83
ZipArchiveWriter(const ZipArchiveWriter &)=delete
Definition ZipArchiveWriter.hpp:19
Definition ZipArchiveWriter.cpp:18