summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDees Troy <dees_troy@teamw.in>2017-02-08 04:23:49 +0100
committerGerrit Code Review <gerrit2@gerrit>2017-02-08 04:23:49 +0100
commitb5e7ca96ef4a98c33b5724bd4caef2132d198b0e (patch)
tree384abee903f0101939f72a3209c63b9ae2dcb29c
parentMerge "Adjust & Improve Chinese translations for zh_CN/TW again" into android-7.1 (diff)
parentFix crash during check for TWRP app (diff)
downloadandroid_bootable_recovery-b5e7ca96ef4a98c33b5724bd4caef2132d198b0e.tar
android_bootable_recovery-b5e7ca96ef4a98c33b5724bd4caef2132d198b0e.tar.gz
android_bootable_recovery-b5e7ca96ef4a98c33b5724bd4caef2132d198b0e.tar.bz2
android_bootable_recovery-b5e7ca96ef4a98c33b5724bd4caef2132d198b0e.tar.lz
android_bootable_recovery-b5e7ca96ef4a98c33b5724bd4caef2132d198b0e.tar.xz
android_bootable_recovery-b5e7ca96ef4a98c33b5724bd4caef2132d198b0e.tar.zst
android_bootable_recovery-b5e7ca96ef4a98c33b5724bd4caef2132d198b0e.zip
-rw-r--r--gui/action.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/gui/action.cpp b/gui/action.cpp
index 9c8af35f4..3899f5047 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -1910,21 +1910,21 @@ int GUIAction::checkforapp(std::string arg __unused)
}
}
if (PartitionManager.Mount_By_Path("/data", false)) {
- string parent_path = "/data/app";
- DIR *d = opendir("/data/app");
- struct dirent *p;
- size_t len = strlen("me.twrp.twrpapp-");
- while ((p = readdir(d))) {
- if (!strcmp(p->d_name, ".") || !strcmp(p->d_name, ".."))
- continue;
- if (p->d_type == DT_DIR && strlen(p->d_name) >= len && strncmp(p->d_name, "me.twrp.twrpapp-", len) == 0) {
- LOGINFO("App found at %s/%s\n", parent_path.c_str(), p->d_name);
+ const char parent_path[] = "/data/app";
+ const char app_prefix[] = "me.twrp.twrpapp-";
+ DIR *d = opendir(parent_path);
+ if (d) {
+ struct dirent *p;
+ while ((p = readdir(d))) {
+ if (p->d_type != DT_DIR || strlen(p->d_name) < strlen(app_prefix) || strncmp(p->d_name, app_prefix, strlen(app_prefix)))
+ continue;
closedir(d);
+ LOGINFO("App found at '%s/%s'\n", parent_path, p->d_name);
DataManager::SetValue("tw_app_install_status", 2); // 0 = no status, 1 = not installed, 2 = already installed
goto exit;
}
+ closedir(d);
}
- closedir(d);
}
} else
simulate_progress_bar();