summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Mower <mowerm@gmail.com>2014-03-31 22:58:40 +0200
committerGerrit Code Review <gerrit2@gerrit>2014-04-15 15:28:45 +0200
commit50248ab86b63e76a1a341f170676c59c4e5fb166 (patch)
treedb541a7c6b7eaff4edbc4add0a38bdfbbf9ceb12
parentEnable rk30xx hack (diff)
downloadandroid_bootable_recovery-50248ab86b63e76a1a341f170676c59c4e5fb166.tar
android_bootable_recovery-50248ab86b63e76a1a341f170676c59c4e5fb166.tar.gz
android_bootable_recovery-50248ab86b63e76a1a341f170676c59c4e5fb166.tar.bz2
android_bootable_recovery-50248ab86b63e76a1a341f170676c59c4e5fb166.tar.lz
android_bootable_recovery-50248ab86b63e76a1a341f170676c59c4e5fb166.tar.xz
android_bootable_recovery-50248ab86b63e76a1a341f170676c59c4e5fb166.tar.zst
android_bootable_recovery-50248ab86b63e76a1a341f170676c59c4e5fb166.zip
Diffstat (limited to '')
-rw-r--r--twrpDU.cpp10
-rw-r--r--twrpDU.hpp2
-rw-r--r--twrpTar.cpp35
3 files changed, 14 insertions, 33 deletions
diff --git a/twrpDU.cpp b/twrpDU.cpp
index 38eb4e02a..28c3dfa15 100644
--- a/twrpDU.cpp
+++ b/twrpDU.cpp
@@ -41,7 +41,6 @@ twrpDU::twrpDU() {
#ifdef RECOVERY_SDCARD_ON_DATA
add_absolute_dir("/data/media");
#endif
- parent = "";
}
void twrpDU::add_relative_dir(const string& dir) {
@@ -80,7 +79,7 @@ uint64_t twrpDU::Get_Folder_Size(const string& Path) {
}
while ((de = readdir(d)) != NULL) {
- if (de->d_type == DT_DIR && !check_skip_dirs(Path, de->d_name)) {
+ if (de->d_type == DT_DIR && !check_skip_dirs(Path + "/" + de->d_name)) {
dusize += Get_Folder_Size(Path + "/" + de->d_name);
} else if (de->d_type == DT_REG) {
stat((Path + "/" + de->d_name).c_str(), &st);
@@ -96,12 +95,7 @@ bool twrpDU::check_relative_skip_dirs(const string& dir) {
}
bool twrpDU::check_absolute_skip_dirs(const string& path) {
- string normalized = TWFunc::Remove_Trailing_Slashes(path);
- return std::find(absolutedir.begin(), absolutedir.end(), normalized) != absolutedir.end();
-}
-
-bool twrpDU::check_skip_dirs(const string& parent, const string& dir) {
- return check_relative_skip_dirs(dir) || check_absolute_skip_dirs(parent + "/" + dir);
+ return std::find(absolutedir.begin(), absolutedir.end(), path) != absolutedir.end();
}
bool twrpDU::check_skip_dirs(const string& path) {
diff --git a/twrpDU.hpp b/twrpDU.hpp
index 91f5039a7..e947de9c2 100644
--- a/twrpDU.hpp
+++ b/twrpDU.hpp
@@ -42,14 +42,12 @@ public:
void add_relative_dir(const string& Path);
bool check_relative_skip_dirs(const string& dir);
bool check_absolute_skip_dirs(const string& path);
- bool check_skip_dirs(const string& parent, const string& dir);
bool check_skip_dirs(const string& path);
vector<string> get_absolute_dirs(void);
void clear_relative_dir(string dir);
private:
vector<string> absolutedir;
vector<string> relativedir;
- string parent;
};
extern twrpDU du;
diff --git a/twrpTar.cpp b/twrpTar.cpp
index f6282e73b..7f00da5c7 100644
--- a/twrpTar.cpp
+++ b/twrpTar.cpp
@@ -114,13 +114,11 @@ int twrpTar::createTarFork() {
}
// Figure out the size of all data to be encrypted and create a list of unencrypted files
while ((de = readdir(d)) != NULL) {
- FileName = tardir + "/";
- FileName += de->d_name;
- if (has_data_media == 1 && FileName.size() >= 11 && strncmp(FileName.c_str(), "/data/media", 11) == 0)
- continue; // Skip /data/media
- if (de->d_type == DT_BLK || de->d_type == DT_CHR)
+ FileName = tardir + "/" + de->d_name;
+
+ if (de->d_type == DT_BLK || de->d_type == DT_CHR || du.check_skip_dirs(FileName))
continue;
- if (de->d_type == DT_DIR && !du.check_skip_dirs(tardir, de->d_name)) {
+ if (de->d_type == DT_DIR) {
item_len = strlen(de->d_name);
if (userdata_encryption && ((item_len >= 3 && strncmp(de->d_name, "app", 3) == 0) || (item_len >= 6 && strncmp(de->d_name, "dalvik", 6) == 0))) {
if (Generate_TarList(FileName, &RegularList, &target_size, &regular_thread_id) < 0) {
@@ -158,19 +156,16 @@ int twrpTar::createTarFork() {
}
// Divide up the encrypted file list for threading
while ((de = readdir(d)) != NULL) {
- FileName = tardir + "/";
- FileName += de->d_name;
- if (has_data_media == 1 && FileName.size() >= 11 && strncmp(FileName.c_str(), "/data/media", 11) == 0)
- continue; // Skip /data/media
- if (de->d_type == DT_BLK || de->d_type == DT_CHR)
+ FileName = tardir + "/" + de->d_name;
+
+ if (de->d_type == DT_BLK || de->d_type == DT_CHR || du.check_skip_dirs(FileName))
continue;
- if (de->d_type == DT_DIR && !du.check_skip_dirs(tardir, de->d_name)) {
+ if (de->d_type == DT_DIR) {
item_len = strlen(de->d_name);
if (userdata_encryption && ((item_len >= 3 && strncmp(de->d_name, "app", 3) == 0) || (item_len >= 6 && strncmp(de->d_name, "dalvik", 6) == 0))) {
// Do nothing, we added these to RegularList earlier
} else {
- FileName = tardir + "/";
- FileName += de->d_name;
+ FileName = tardir + "/" + de->d_name;
if (Generate_TarList(FileName, &EncryptList, &target_size, &enc_thread_id) < 0) {
LOGERR("Error in Generate_TarList with encrypted list!\n");
closedir(d);
@@ -446,9 +441,6 @@ int twrpTar::Generate_TarList(string Path, std::vector<TarListStruct> *TarList,
struct TarListStruct TarItem;
string::size_type i;
- if (has_data_media == 1 && Path.size() >= 11 && strncmp(Path.c_str(), "/data/media", 11) == 0)
- return 0; // Skip /data/media
-
d = opendir(Path.c_str());
if (d == NULL) {
LOGERR("Error opening '%s' -- error: %s\n", Path.c_str(), strerror(errno));
@@ -456,16 +448,13 @@ int twrpTar::Generate_TarList(string Path, std::vector<TarListStruct> *TarList,
return -1;
}
while ((de = readdir(d)) != NULL) {
- FileName = Path + "/";
- FileName += de->d_name;
+ FileName = Path + "/" + de->d_name;
- if (has_data_media == 1 && FileName.size() >= 11 && strncmp(FileName.c_str(), "/data/media", 11) == 0)
- continue; // Skip /data/media
- if (de->d_type == DT_BLK || de->d_type == DT_CHR)
+ if (de->d_type == DT_BLK || de->d_type == DT_CHR || du.check_skip_dirs(FileName))
continue;
TarItem.fn = FileName;
TarItem.thread_id = *thread_id;
- if (de->d_type == DT_DIR && !du.check_skip_dirs(Path, de->d_name)) {
+ if (de->d_type == DT_DIR) {
TarList->push_back(TarItem);
if (Generate_TarList(FileName, TarList, Target_Size, thread_id) < 0)
return -1;