2023-03-31 23:18:41 -04:00
|
|
|
#pragma once
|
|
|
|
///@file
|
|
|
|
|
2019-09-11 13:10:46 +02:00
|
|
|
#include "serialise.hh"
|
2023-12-21 04:28:06 -05:00
|
|
|
#include "fs-sink.hh"
|
2019-12-10 15:47:38 +07:00
|
|
|
#include <archive.h>
|
2019-09-11 13:10:46 +02:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
2019-12-10 15:47:38 +07:00
|
|
|
struct TarArchive {
|
2021-04-15 13:51:00 +02:00
|
|
|
struct archive * archive;
|
|
|
|
Source * source;
|
2019-12-10 15:47:38 +07:00
|
|
|
std::vector<unsigned char> buffer;
|
|
|
|
|
2021-04-15 13:51:00 +02:00
|
|
|
void check(int err, const std::string & reason = "failed to extract archive (%s)");
|
2019-12-10 15:47:38 +07:00
|
|
|
|
2021-04-15 13:51:00 +02:00
|
|
|
TarArchive(Source & source, bool raw = false);
|
2019-12-10 15:47:38 +07:00
|
|
|
|
2021-04-15 13:51:00 +02:00
|
|
|
TarArchive(const Path & path);
|
2019-12-10 15:47:38 +07:00
|
|
|
|
2023-03-26 21:12:25 -04:00
|
|
|
/// disable copy constructor
|
2021-04-15 13:51:00 +02:00
|
|
|
TarArchive(const TarArchive &) = delete;
|
2019-12-10 15:47:38 +07:00
|
|
|
|
|
|
|
void close();
|
|
|
|
|
|
|
|
~TarArchive();
|
|
|
|
};
|
2023-01-31 23:14:48 +01:00
|
|
|
|
2019-09-11 15:25:43 +02:00
|
|
|
void unpackTarfile(Source & source, const Path & destDir);
|
|
|
|
|
2019-12-07 22:35:14 +07:00
|
|
|
void unpackTarfile(const Path & tarFile, const Path & destDir);
|
2019-09-11 13:10:46 +02:00
|
|
|
|
2023-12-21 04:28:06 -05:00
|
|
|
time_t unpackTarfileToSink(TarArchive & archive, FileSystemObjectSink & parseSink);
|
|
|
|
|
2019-09-11 13:10:46 +02:00
|
|
|
}
|