summaryrefslogtreecommitdiff
path: root/tools/aapt/Utils.cpp
diff options
context:
space:
mode:
author Tomasz Wasilczyk <twasilczyk@google.com> 2023-08-23 02:22:53 +0000
committer Tomasz Wasilczyk <twasilczyk@google.com> 2023-09-01 19:05:34 +0000
commit804e819c1bf64d4df483107e02e896b29e58b3f1 (patch)
tree300e8f502c5ca18104016ebe30885d0aecf49125 /tools/aapt/Utils.cpp
parentcc7212ddf54bc9ec55d1f08db39833a7c3d91078 (diff)
Move String8 path functions to androidfw and aapt
Test: m checkbuild Bug: 295394788 Change-Id: I9488bc5632cbd47c83f6b5f2df4c87eb324a1e8e
Diffstat (limited to 'tools/aapt/Utils.cpp')
-rw-r--r--tools/aapt/Utils.cpp23
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;
+}