blob: db9cf9bb85c981befa5aabb7788eff8badaa5f16 [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:
bigbiff bigbiff3bf2b0e2013-01-21 21:26:43 -050035 int extract();
bigbiff bigbiff9c754052013-01-09 09:09:08 -050036 int compress(string fn);
bigbiff bigbiff9c754052013-01-09 09:09:08 -050037 int uncompress(string fn);
38 int addFilesToExistingTar(vector <string> files, string tarFile);
bigbiff bigbiff3bf2b0e2013-01-21 21:26:43 -050039 int createTar();
bigbiff bigbiff9c754052013-01-09 09:09:08 -050040 int addFile(string fn, bool include_root);
bigbiff bigbiff3bf2b0e2013-01-21 21:26:43 -050041 int closeTar(bool gzip);
42 int createTarGZThread();
43 int createTarThread();
44 int extractTarThread();
45 int splitArchiveThread();
46 void setfn(string fn);
47 void setdir(string dir);
bigbiff bigbiff9c754052013-01-09 09:09:08 -050048 private:
bigbiff bigbiff3bf2b0e2013-01-21 21:26:43 -050049 int createTGZ();
50 int create();
51 int Split_Archive();
bigbiff bigbiff9c754052013-01-09 09:09:08 -050052 int removeEOT(string tarFile);
bigbiff bigbiff3bf2b0e2013-01-21 21:26:43 -050053 int extractTar();
54 int tarDirs(bool include_root);
55 int Generate_Multiple_Archives(string Path);
56 string Strip_Root_Dir(string Path);
57 int extractTGZ();
58 int openTar(bool gzip);
bigbiff bigbiff9c754052013-01-09 09:09:08 -050059 int has_data_media;
60 int Archive_File_Count;
61 unsigned long long Archive_Current_Size;
bigbiff bigbiff9c754052013-01-09 09:09:08 -050062 TAR *t;
63 FILE* p;
64 int fd;
bigbiff bigbiff3bf2b0e2013-01-21 21:26:43 -050065 string tardir;
66 string tarfn;
67 string basefn;
68 typedef int (twrpTar::*ThreadPtr)(void);
69 typedef void* (*PThreadPtr)(void*);
bigbiff bigbiff9c754052013-01-09 09:09:08 -050070};