aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/tarfile.hh
blob: 237d18c31a8548eb1e85e629b4170b216860f194 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once
///@file

#include "serialise.hh"
#include <archive.h>

namespace nix {

struct TarArchive {
    struct archive * archive;
    Source * source;
    std::vector<unsigned char> buffer;

    void check(int err, const std::string & reason = "failed to extract archive (%s)");

    TarArchive(Source & source, bool raw = false);

    TarArchive(const Path & path);

    /// disable copy constructor
    TarArchive(const TarArchive &) = delete;

    void close();

    ~TarArchive();
};

void unpackTarfile(Source & source, const Path & destDir);

void unpackTarfile(const Path & tarFile, const Path & destDir);

}