2019-09-11 11:10:46 +00:00
|
|
|
#include "serialise.hh"
|
2019-12-10 08:47:38 +00:00
|
|
|
#include <archive.h>
|
2019-09-11 11:10:46 +00:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
2019-12-10 08:47:38 +00:00
|
|
|
struct TarArchive {
|
2021-04-15 11:51:00 +00:00
|
|
|
struct archive * archive;
|
|
|
|
Source * source;
|
2019-12-10 08:47:38 +00:00
|
|
|
std::vector<unsigned char> buffer;
|
|
|
|
|
2021-04-15 11:51:00 +00:00
|
|
|
void check(int err, const std::string & reason = "failed to extract archive (%s)");
|
2019-12-10 08:47:38 +00:00
|
|
|
|
2021-04-15 11:51:00 +00:00
|
|
|
TarArchive(Source & source, bool raw = false);
|
2019-12-10 08:47:38 +00:00
|
|
|
|
2021-04-15 11:51:00 +00:00
|
|
|
TarArchive(const Path & path);
|
2019-12-10 08:47:38 +00:00
|
|
|
|
|
|
|
// disable copy constructor
|
2021-04-15 11:51:00 +00:00
|
|
|
TarArchive(const TarArchive &) = delete;
|
2019-12-10 08:47:38 +00:00
|
|
|
|
|
|
|
void close();
|
|
|
|
|
|
|
|
~TarArchive();
|
|
|
|
};
|
2019-09-11 13:25:43 +00:00
|
|
|
void unpackTarfile(Source & source, const Path & destDir);
|
|
|
|
|
2019-12-07 15:35:14 +00:00
|
|
|
void unpackTarfile(const Path & tarFile, const Path & destDir);
|
2019-09-11 11:10:46 +00:00
|
|
|
|
|
|
|
}
|