summaryrefslogtreecommitdiffstats
path: root/twrp-functions.cpp
diff options
context:
space:
mode:
authorDees Troy <dees_troy@teamw.in>2014-03-13 15:17:17 +0100
committerGerrit Code Review <gerrit2@gerrit>2014-03-13 15:17:17 +0100
commit863ecff6102b2370aeb6a2e07349106c1d6135db (patch)
treefe011b564add6f6dae59e7855a423df2ad211869 /twrp-functions.cpp
parentRun TWFunc::Fixup_Time_On_Boot() before OpenRecoveryScript (diff)
parentFix skipping of relative paths and lost+found in twrpDU (diff)
downloadandroid_bootable_recovery-863ecff6102b2370aeb6a2e07349106c1d6135db.tar
android_bootable_recovery-863ecff6102b2370aeb6a2e07349106c1d6135db.tar.gz
android_bootable_recovery-863ecff6102b2370aeb6a2e07349106c1d6135db.tar.bz2
android_bootable_recovery-863ecff6102b2370aeb6a2e07349106c1d6135db.tar.lz
android_bootable_recovery-863ecff6102b2370aeb6a2e07349106c1d6135db.tar.xz
android_bootable_recovery-863ecff6102b2370aeb6a2e07349106c1d6135db.tar.zst
android_bootable_recovery-863ecff6102b2370aeb6a2e07349106c1d6135db.zip
Diffstat (limited to 'twrp-functions.cpp')
-rw-r--r--twrp-functions.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index c50290df4..4551e84b4 100644
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -274,6 +274,31 @@ unsigned long TWFunc::Get_File_Size(string Path) {
return st.st_size;
}
+std::string TWFunc::Remove_Trailing_Slashes(const std::string& path, bool leaveLast)
+{
+ std::string res;
+ size_t last_idx = 0, idx = 0;
+
+ while(last_idx != std::string::npos)
+ {
+ if(last_idx != 0)
+ res += '/';
+
+ idx = path.find_first_of('/', last_idx);
+ if(idx == std::string::npos) {
+ res += path.substr(last_idx, idx);
+ break;
+ }
+
+ res += path.substr(last_idx, idx-last_idx);
+ last_idx = path.find_first_not_of('/', idx);
+ }
+
+ if(leaveLast)
+ res += '/';
+ return res;
+}
+
#ifndef BUILD_TWRPTAR_MAIN
// Returns "/path" from a full /path/to/file.name