summaryrefslogtreecommitdiffstats
path: root/twrp-functions.cpp
diff options
context:
space:
mode:
authorDees_Troy <dees_troy@teamw.in>2013-01-09 20:48:21 +0100
committerDees_Troy <dees_troy@teamw.in>2013-01-09 20:49:19 +0100
commitce67546112ca718d5bbaf9fecadf3652f9c63df5 (patch)
treea914b4a9c8793d88eec087bcf6352b2da4c8c4ae /twrp-functions.cpp
parentImprove remounting sdcard with ecryptfs (diff)
downloadandroid_bootable_recovery-ce67546112ca718d5bbaf9fecadf3652f9c63df5.tar
android_bootable_recovery-ce67546112ca718d5bbaf9fecadf3652f9c63df5.tar.gz
android_bootable_recovery-ce67546112ca718d5bbaf9fecadf3652f9c63df5.tar.bz2
android_bootable_recovery-ce67546112ca718d5bbaf9fecadf3652f9c63df5.tar.lz
android_bootable_recovery-ce67546112ca718d5bbaf9fecadf3652f9c63df5.tar.xz
android_bootable_recovery-ce67546112ca718d5bbaf9fecadf3652f9c63df5.tar.zst
android_bootable_recovery-ce67546112ca718d5bbaf9fecadf3652f9c63df5.zip
Diffstat (limited to '')
-rw-r--r--twrp-functions.cpp52
1 files changed, 26 insertions, 26 deletions
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index 53a13f661..d7596b8a0 100644
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -401,38 +401,38 @@ void TWFunc::check_and_run_script(const char* script_file, const char* display_n
}
int TWFunc::removeDir(const string path, bool skipParent) {
- DIR *d = opendir(path.c_str());
- int r = 0;
- string new_path;
+ DIR *d = opendir(path.c_str());
+ int r = 0;
+ string new_path;
- if (d == NULL) {
- LOGE("Error opening '%s'\n", path.c_str());
- return -1;
- }
+ if (d == NULL) {
+ LOGE("Error opening '%s'\n", path.c_str());
+ return -1;
+ }
- if (d) {
- struct dirent *p;
- while (!r && (p = readdir(d))) {
+ if (d) {
+ struct dirent *p;
+ while (!r && (p = readdir(d))) {
LOGI("checking :%s\n", p->d_name);
- if (!strcmp(p->d_name, ".") || !strcmp(p->d_name, ".."))
- continue;
- new_path = path + "/";
- new_path.append(p->d_name);
- if (p->d_type == DT_DIR) {
- r = removeDir(new_path, true);
- if (!r) {
+ if (!strcmp(p->d_name, ".") || !strcmp(p->d_name, ".."))
+ continue;
+ new_path = path + "/";
+ new_path.append(p->d_name);
+ if (p->d_type == DT_DIR) {
+ r = removeDir(new_path, true);
+ if (!r) {
if (p->d_type == DT_DIR)
r = rmdir(new_path.c_str());
else
LOGI("Unable to removeDir '%s': %s\n", new_path.c_str(), strerror(errno));
}
- } else {
- r = unlink(new_path.c_str());
- if (!r)
- LOGI("Unable to unlink '%s'\n", new_path.c_str());
- }
- }
- closedir(d);
+ } else if (p->d_type == DT_REG || p->d_type == DT_LNK) {
+ r = unlink(new_path.c_str());
+ if (!r)
+ LOGI("Unable to unlink '%s'\n", new_path.c_str());
+ }
+ }
+ closedir(d);
if (!r) {
if (skipParent)
@@ -440,8 +440,8 @@ int TWFunc::removeDir(const string path, bool skipParent) {
else
r = rmdir(path.c_str());
}
- }
- return r;
+ }
+ return r;
}
int TWFunc::copy_file(string src, string dst, int mode) {