summaryrefslogtreecommitdiffstats
path: root/twrp-functions.cpp
diff options
context:
space:
mode:
authorVojtech Bocek <vbocek@gmail.com>2014-03-13 18:46:34 +0100
committerGerrit Code Review <gerrit2@gerrit>2014-07-09 17:35:36 +0200
commit03fd6c56fe57dcd7cc4a7f7166a00ece42491558 (patch)
tree7b273e894f5ed7d2ed97c78813d48088c7884d1a /twrp-functions.cpp
parentCheck the crash counter instead of date in TWFunc::Fixup_Time_On_Boot() (diff)
downloadandroid_bootable_recovery-03fd6c56fe57dcd7cc4a7f7166a00ece42491558.tar
android_bootable_recovery-03fd6c56fe57dcd7cc4a7f7166a00ece42491558.tar.gz
android_bootable_recovery-03fd6c56fe57dcd7cc4a7f7166a00ece42491558.tar.bz2
android_bootable_recovery-03fd6c56fe57dcd7cc4a7f7166a00ece42491558.tar.lz
android_bootable_recovery-03fd6c56fe57dcd7cc4a7f7166a00ece42491558.tar.xz
android_bootable_recovery-03fd6c56fe57dcd7cc4a7f7166a00ece42491558.tar.zst
android_bootable_recovery-03fd6c56fe57dcd7cc4a7f7166a00ece42491558.zip
Diffstat (limited to 'twrp-functions.cpp')
-rw-r--r--twrp-functions.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index 4306c4520..1788c7e61 100644
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -1176,4 +1176,22 @@ std::vector<std::string> TWFunc::Split_String(const std::string& str, const std:
return res;
}
+bool TWFunc::Create_Dir_Recursive(const std::string& path, mode_t mode, uid_t uid, gid_t gid)
+{
+ std::vector<std::string> parts = Split_String(path, "/");
+ std::string cur_path;
+ struct stat info;
+ for(size_t i = 0; i < parts.size(); ++i)
+ {
+ cur_path += "/" + parts[i];
+ if(stat(cur_path.c_str(), &info) < 0 || !S_ISDIR(info.st_mode))
+ {
+ if(mkdir(cur_path.c_str(), mode) < 0)
+ return false;
+ chown(cur_path.c_str(), uid, gid);
+ }
+ }
+ return true;
+}
+
#endif // ndef BUILD_TWRPTAR_MAIN