From 940f49f5dbdb47c19af5e8cee33a0ab438094660 Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Fri, 18 Aug 2017 19:33:03 -0700 Subject: [PATCH] AAPT2: Fix mkdirs implementation Once switched to using std::string, the mkdirs implementation was trying to create an empty string when an absolute file path on linux or macOS was used. Bug: 62336414 Test: manual Change-Id: I52f3050b410a923ca48f353b0983667c16d00ee8 --- tools/aapt2/util/Files.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/aapt2/util/Files.cpp b/tools/aapt2/util/Files.cpp index 6f97efe379215..bf8dc4d727f76 100644 --- a/tools/aapt2/util/Files.cpp +++ b/tools/aapt2/util/Files.cpp @@ -94,7 +94,9 @@ FileType GetFileType(const std::string& path) { bool mkdirs(const std::string& path) { constexpr const mode_t mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP; - size_t current_pos = 0u; + // Start after the first character so that we don't consume the root '/'. + // This is safe to do with unicode because '/' will never match with a continuation character. + size_t current_pos = 1u; while ((current_pos = path.find(sDirSep, current_pos)) != std::string::npos) { std::string parent_path = path.substr(0, current_pos); int result = ::android::base::utf8::mkdir(parent_path.c_str(), mode);