summaryrefslogtreecommitdiffstats
path: root/twrpTar.hpp
blob: 3ee6028a5696d839fe993b557b952e5bf6623fde (plain) (blame)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
        Copyright 2012 bigbiff/Dees_Troy TeamWin
        This file is part of TWRP/TeamWin Recovery Project.

        TWRP is free software: you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation, either version 3 of the License, or
        (at your option) any later version.

        TWRP is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.

        You should have received a copy of the GNU General Public License
        along with TWRP.  If not, see <http://www.gnu.org/licenses/>.
*/

extern "C" {
        #include "libtar/libtar.h"
}
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <fstream>
#include <string>
#include <vector>

using namespace std;

class twrpTar {
	public:
		int extract();
		int compress(string fn);
		int uncompress(string fn);
                int addFilesToExistingTar(vector <string> files, string tarFile);
		int createTar();
		int addFile(string fn, bool include_root);
		int entryExists(string entry);
		int closeTar(bool gzip);
		int createTarGZFork();
		int createTarFork();
		int extractTarFork();
		int splitArchiveFork();
                void setfn(string fn);
                void setdir(string dir);
	private:
		int createTGZ();
		int create();
		int Split_Archive();
		int removeEOT(string tarFile);
		int extractTar();
		int tarDirs(bool include_root);
		int Generate_Multiple_Archives(string Path);
		string Strip_Root_Dir(string Path);
		int extractTGZ();
		int openTar(bool gzip);
		int has_data_media;
		int Archive_File_Count;
		unsigned long long Archive_Current_Size;
		int getArchiveType(); // 1 for compressed - 0 for uncompressed
		TAR *t;
		FILE* p;
		int fd;
		string tardir;
		string tarfn;
		string basefn;
};