From 50248ab86b63e76a1a341f170676c59c4e5fb166 Mon Sep 17 00:00:00 2001 From: Matt Mower Date: Mon, 31 Mar 2014 15:58:40 -0500 Subject: Simplify twrpTar skip dir checks, DU code cleanup * Remove unused parent variable from twruDU constructor * Replace manual checks for /data/media with DU's check_skip_dirs() function * Remove check_skip_dirs(A,B) function which duplicates the functionality of check_skip_dirs(A) * Remove redundant trailing slash removal from check_absolute_skip_dirs(); this function is only accessed through check_skip_dirs() Change-Id: Icfe8d71de36e33db6749fc5896dd3eafbcf7c9a4 --- twrpDU.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'twrpDU.cpp') 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) { -- cgit v1.2.3