blob: 554a01dbdbba0eb8192b91deb61190898416f838 [file] [log] [blame]
bigbiff bigbiff9c754052013-01-09 09:09:08 -05001/*
2 Copyright 2012 bigbiff/Dees_Troy TeamWin
3 This file is part of TWRP/TeamWin Recovery Project.
4
5 TWRP is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 TWRP is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with TWRP. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19extern "C" {
20 #include "libtar/libtar.h"
21}
22#include <sys/types.h>
23#include <sys/stat.h>
24#include <string.h>
25#include <errno.h>
26#include <fcntl.h>
27#include <fstream>
28#include <string>
29#include <vector>
30
31using namespace std;
32
33class twrpTar {
34 public:
35 int create(string dir, string fn);
36 int createTGZ(string dir, string fn);
37 int extract(string rootDir, string fn);
38 int compress(string fn);
39 int extractTGZ(string rootdir, string fn);
40 int uncompress(string fn);
41 int addFilesToExistingTar(vector <string> files, string tarFile);
42 int createTar(string dir, string fn);
43 int openTar(string rootdir, string fn, bool gzip);
44 int addFile(string fn, bool include_root);
45 int closeTar(string fn, bool gzip);
46 int Split_Archive(string Path, string fn);
47 private:
48 int removeEOT(string tarFile);
49 int extractTar(string rootdir, string fn);
50 int tarDirs(string dir, string fn, bool include_root);
51 int Generate_Multiple_Archives(string Path, string fn);
52
53 private:
54 int has_data_media;
55 int Archive_File_Count;
56 unsigned long long Archive_Current_Size;
57 string Strip_Root_Dir(string Path);
58 TAR *t;
59 FILE* p;
60 int fd;
61};