Improve backup & wipe exclusion handling

Rename twrpDU.* to exclude.*
Remove global variable for du and replace with partition specific
variables.
Use separate exclusion lists for backups and wiping.
Clean up some includes
Fix some parenthesis in twrp.cpp that I messed up.

Note: twrpTarMain command line utility compiles but probably does
not work correctly yet due to not properly setting part_settings

Change-Id: Idec9c3e6a8782ba53f3420fa79ba33394f4f85fb
diff --git a/twrpTar.cpp b/twrpTar.cpp
index 06e3b62..3c07a97 100644
--- a/twrpTar.cpp
+++ b/twrpTar.cpp
@@ -71,6 +71,7 @@
 	tar_type.readfunc = read;
 	input_fd = -1;
 	output_fd = -1;
+	backup_exclusions = NULL;
 }
 
 twrpTar::~twrpTar(void) {
@@ -108,12 +109,18 @@
 	char cmd[512];
 
 	file_count = 0;
+	if (backup_exclusions == NULL) {
+		LOGINFO("backup_exclusions is NULL\n");
+		return -1;
+	}
 
+#ifndef BUILD_TWRPTAR_MAIN
 	if (part_settings->adbbackup) {
 		std::string Backup_FileName(tarfn);
 		if (!twadbbu::Write_TWFN(Backup_FileName, Total_Backup_Size, use_compression))
 			return -1;
 	}
+#endif
 
 	if (pipe(progress_pipe) < 0) {
 		LOGINFO("Error creating progress tracking pipe\n");
@@ -168,7 +175,7 @@
 			while ((de = readdir(d)) != NULL) {
 				FileName = tardir + "/" + de->d_name;
 
-				if (de->d_type == DT_BLK || de->d_type == DT_CHR || du.check_skip_dirs(FileName))
+				if (de->d_type == DT_BLK || de->d_type == DT_CHR || backup_exclusions->check_skip_dirs(FileName))
 					continue;
 				if (de->d_type == DT_DIR) {
 					item_len = strlen(de->d_name);
@@ -183,9 +190,9 @@
 							_exit(-1);
 						}
 						file_count = (unsigned long long)(ret);
-						regular_size += du.Get_Folder_Size(FileName);
+						regular_size += backup_exclusions->Get_Folder_Size(FileName);
 					} else {
-						encrypt_size += du.Get_Folder_Size(FileName);
+						encrypt_size += backup_exclusions->Get_Folder_Size(FileName);
 					}
 				} else if (de->d_type == DT_REG) {
 					stat(FileName.c_str(), &st);
@@ -216,7 +223,7 @@
 			while ((de = readdir(d)) != NULL) {
 				FileName = tardir + "/" + de->d_name;
 
-				if (de->d_type == DT_BLK || de->d_type == DT_CHR || du.check_skip_dirs(FileName))
+				if (de->d_type == DT_BLK || de->d_type == DT_CHR || backup_exclusions->check_skip_dirs(FileName))
 					continue;
 				if (de->d_type == DT_DIR) {
 					item_len = strlen(de->d_name);
@@ -657,7 +664,7 @@
 	while ((de = readdir(d)) != NULL) {
 		FileName = Path + "/" + de->d_name;
 
-		if (de->d_type == DT_BLK || de->d_type == DT_CHR || du.check_skip_dirs(FileName))
+		if (de->d_type == DT_BLK || de->d_type == DT_CHR || backup_exclusions->check_skip_dirs(FileName))
 			continue;
 		TarItem.fn = FileName;
 		TarItem.thread_id = *thread_id;
@@ -698,10 +705,12 @@
 		gui_err("restore_error=Error during restore process.");
 		return -1;
 	}
+#ifndef BUILD_TWRPTAR_MAIN
 	if (part_settings->adbbackup) {
 		if (!twadbbu::Write_TWEOF())
 			return -1;
 	}
+#endif
 	return 0;
 }
 
@@ -1404,8 +1413,10 @@
 #endif
 	}
 	else {
+#ifndef BUILD_TWRPTAR_MAIN
 		if (!twadbbu::Write_TWEOF())
 			return -1;
+#endif
 	}
 	if (input_fd >= 0)
 		close(input_fd);