1
0
mirror of synced 2024-11-15 11:33:23 +01:00
ImHex/lib/libimhex/include/hex/helpers/tar.hpp
WerWolv 966f3b8597
sys: Replace existing bad project system with a much better one (#663)
* sys: Initial effort to replace existing project files with a better system

* sys: Added back marking provider as dirty

* sys: Remove git commit information from project files

* sys: Format data processor save file nicely

* fix: Automatic pattern loading not working correctly

* ui: Added warning popup when closing a provider with modifications

Closes #604

* sys: Fixed build issues

* tests: Removed useless debug logs

* patterns: Updated pattern language

* sys: Added log message when crashing with a signal

* sys: Make sure abnormal termination handlers are being called more reliably
2022-08-08 21:23:52 +02:00

49 lines
1.2 KiB
C++

#pragma once
#include <hex.hpp>
#include <hex/helpers/fs.hpp>
#include <microtar.h>
namespace hex {
class Tar {
public:
enum class Mode {
Read,
Write,
Create
};
Tar() = default;
Tar(const std::fs::path &path, Mode mode);
~Tar();
Tar(const Tar&) = delete;
Tar(Tar&&) noexcept;
Tar &operator=(Tar &&other) noexcept;
void close();
[[nodiscard]] std::vector<u8> read(const std::fs::path &path);
[[nodiscard]] std::string readString(const std::fs::path &path);
void write(const std::fs::path &path, const std::vector<u8> &data);
void write(const std::fs::path &path, const std::string &data);
[[nodiscard]] std::vector<std::fs::path> listEntries(const std::fs::path &basePath = "/");
[[nodiscard]] bool contains(const std::fs::path &path);
void extract(const std::fs::path &path, const std::fs::path &outputPath);
void extractAll(const std::fs::path &outputPath);
[[nodiscard]] bool isValid() const { return this->m_valid; }
private:
mtar_t m_ctx = { };
bool m_valid = false;
};
}