diff options
author | 2023-09-06 19:46:54 +0000 | |
---|---|---|
committer | 2023-09-06 19:46:54 +0000 | |
commit | aa95ff271a31f903727c5ebc2e4990846c2073d2 (patch) | |
tree | 247609dc143ce6d8fc0c588fb8b8ef15bbd1d172 /tools/aapt/Utils.cpp | |
parent | b61b138892b337b9abf7082dde5c7c17eb82ab49 (diff) | |
parent | 4fb86ec92a08a65e2ab52f8e361edb15b380cfc4 (diff) |
Merge "Move String8 path functions to androidfw and aapt" into main am: 713e3930c4 am: 0cfc1c6ddd am: 9a80e1b70c am: 13ab173d41 am: 4fb86ec92a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2723454
Change-Id: I91016723c47501051b8768c0ee29f8821cab0331
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'tools/aapt/Utils.cpp')
-rw-r--r-- | tools/aapt/Utils.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/aapt/Utils.cpp b/tools/aapt/Utils.cpp index 36b018e7dd2c..946916a0598a 100644 --- a/tools/aapt/Utils.cpp +++ b/tools/aapt/Utils.cpp @@ -36,3 +36,26 @@ void convertToResPath([[maybe_unused]] String8& s) { } #endif } + +String8 walkPath(const String8& path, String8* outRemains) { + const char* cp; + const char* const str = path.c_str(); + const char* buf = str; + + cp = strchr(buf, OS_PATH_SEPARATOR); + if (cp == buf) { + // don't include a leading '/'. + buf = buf + 1; + cp = strchr(buf, OS_PATH_SEPARATOR); + } + + if (cp == nullptr) { + String8 res = buf != str ? String8(buf) : path; + if (outRemains) *outRemains = String8(); + return res; + } + + String8 res(buf, cp - buf); + if (outRemains) *outRemains = String8(cp + 1); + return res; +} |