Adaptyst
A comprehensive and architecture-agnostic performance analysis tool
Loading...
Searching...
No Matches
archive.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 CERN
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#ifndef ARCHIVE_HPP_
5#define ARCHIVE_HPP_
6
7#include "adaptyst/socket.hpp"
8#include <filesystem>
9#include <istream>
10#include <archive.h>
11#include <archive_entry.h>
12#include <nlohmann/json.hpp>
13#include <unordered_set>
14
15namespace adaptyst {
16 namespace fs = std::filesystem;
17
21 class Archive {
22 private:
23 struct archive *arch;
24 struct archive_entry *arch_entry;
25 unsigned int buf_size;
26 std::unique_ptr<Connection> conn;
27
28 public:
41 Archive(fs::path path, unsigned int buf_size = 1024);
42
59 Archive(std::unique_ptr<Connection> &conn, bool padding = true,
60 unsigned int buf_size = 1024);
61
69 void add_file(std::string filename, fs::path path);
70
81 void add_file_stream(std::string filename, std::istream &stream,
82 unsigned int size);
83
88 void close();
89
90 ~Archive();
91
92 class Exception : public std::exception {
93 private:
94 const char *message;
95
96 public:
97 Exception(struct archive *arch) {
98 this->message = archive_error_string(arch);
99 }
100
102 this->message = typeid(*this).name();
103 }
104
105 const char *what() const noexcept override {
106 return this->message;
107 }
108 };
109
110 class InitException : public Exception { using Exception::Exception; };
111 class FileExistsException : public Exception { using Exception::Exception; };
112 class FileOpenException : public Exception { using Exception::Exception; };
113 class FileIOException : public Exception { using Exception::Exception; };
114 class CloseException : public Exception { using Exception::Exception; };
115 class AlreadyClosedException : public Exception { using Exception::Exception; };
116 class FileDoesNotExistException : public Exception { using Exception::Exception; };
117 class NotRegularFileException : public Exception { using Exception::Exception; };
118 };
119};
120
121#endif
Definition archive.hpp:114
const char * what() const noexcept override
Definition archive.hpp:105
Exception()
Definition archive.hpp:101
Exception(struct archive *arch)
Definition archive.hpp:97
Definition archive.hpp:111
Definition archive.hpp:113
Definition archive.hpp:112
Definition archive.hpp:110
void add_file(std::string filename, fs::path path)
Definition archive.cpp:108
Archive(fs::path path, unsigned int buf_size=1024)
Definition archive.cpp:8
~Archive()
Definition archive.cpp:243
void add_file_stream(std::string filename, std::istream &stream, unsigned int size)
Definition archive.cpp:164
void close()
Definition archive.cpp:231
Definition output.hpp:12