From 03fd6c56fe57dcd7cc4a7f7166a00ece42491558 Mon Sep 17 00:00:00 2001 From: Vojtech Bocek Date: Thu, 13 Mar 2014 18:46:34 +0100 Subject: Implement "take a screenshot" feature * Like in android - press power+volume down, screenshots are saved in /sdcard/Pictures/Screenshots (if /sdcard is mounted) or /tmp Change-Id: Iaefa15b11a1d5fdfac57d77388db1621f378a8d4 Signed-off-by: Vojtech Bocek --- twrp-functions.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'twrp-functions.cpp') 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 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 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 -- cgit v1.2.3