summaryrefslogtreecommitdiffstats
path: root/twrp-functions.cpp
diff options
context:
space:
mode:
authorthat <github@that.at>2016-01-03 11:09:15 +0100
committerDees Troy <dees_troy@teamw.in>2016-01-04 14:13:40 +0100
commitf1408b3c0f9e45b4d080a9bd0c1e479c2067e872 (patch)
treeeb6b26055d7d6ab30b6463d10fed80c863435105 /twrp-functions.cpp
parentgui: PatternPassword: allow any N*N grid (diff)
downloadandroid_bootable_recovery-f1408b3c0f9e45b4d080a9bd0c1e479c2067e872.tar
android_bootable_recovery-f1408b3c0f9e45b4d080a9bd0c1e479c2067e872.tar.gz
android_bootable_recovery-f1408b3c0f9e45b4d080a9bd0c1e479c2067e872.tar.bz2
android_bootable_recovery-f1408b3c0f9e45b4d080a9bd0c1e479c2067e872.tar.lz
android_bootable_recovery-f1408b3c0f9e45b4d080a9bd0c1e479c2067e872.tar.xz
android_bootable_recovery-f1408b3c0f9e45b4d080a9bd0c1e479c2067e872.tar.zst
android_bootable_recovery-f1408b3c0f9e45b4d080a9bd0c1e479c2067e872.zip
Diffstat (limited to 'twrp-functions.cpp')
-rw-r--r--twrp-functions.cpp23
1 files changed, 8 insertions, 15 deletions
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index a7a8e8d63..6eb6cd59d 100644
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -403,26 +403,19 @@ void TWFunc::htc_dumlock_reflash_recovery_to_boot(void) {
}
int TWFunc::Recursive_Mkdir(string Path) {
- string pathCpy = Path;
- string wholePath;
- size_t pos = pathCpy.find("/", 2);
-
- while (pos != string::npos)
- {
- wholePath = pathCpy.substr(0, pos);
- if (!TWFunc::Path_Exists(wholePath)) {
- if (mkdir(wholePath.c_str(), 0777)) {
- gui_msg(Msg(msg::kError, "create_folder_strerr=Can not create '{1}' folder ({2})")(wholePath)(strerror(errno)));
+ std::vector<std::string> parts = Split_String(Path, "/", true);
+ std::string cur_path;
+ for (size_t i = 0; i < parts.size(); ++i) {
+ cur_path += "/" + parts[i];
+ if (!TWFunc::Path_Exists(cur_path)) {
+ if (mkdir(cur_path.c_str(), 0777)) {
+ gui_msg(Msg(msg::kError, "create_folder_strerr=Can not create '{1}' folder ({2})")(cur_path)(strerror(errno)));
return false;
} else {
- tw_set_default_metadata(wholePath.c_str());
+ tw_set_default_metadata(cur_path.c_str());
}
}
-
- pos = pathCpy.find("/", pos + 1);
}
- if (mkdir(wholePath.c_str(), 0777) && errno != EEXIST)
- return false;
return true;
}