From 9109a415b28aea8bf3bf668acbbbcdc28ca197ac Mon Sep 17 00:00:00 2001 From: Luke Edgar Date: Mon, 8 Nov 2021 12:57:40 +0000 Subject: [PATCH] AAPT Files - Permit invariant filepaths for getting file names AAPT compile provides a "--source-path" option that instructs aapt to use a provided source path rather than the default source resource as resource orgin. However, this is not file system agnostic. This causes incorrect outputs of AAPT link, as source path parsing is tied to the file system. This change ensures that AAPT Files::getFilename can parse filepaths, regardless of file system filepath type. Bug: 141301405, 155218379 Test: manually tested on windows with a unix style filepath, passes aapt tests Change-Id: I548de01ad513b549dc30eb35d2a59813fa3d4e69 --- tools/aapt2/util/Files.cpp | 2 +- tools/aapt2/util/Files.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/aapt2/util/Files.cpp b/tools/aapt2/util/Files.cpp index 5d57de6a9fb1b..be09545abb450 100644 --- a/tools/aapt2/util/Files.cpp +++ b/tools/aapt2/util/Files.cpp @@ -154,7 +154,7 @@ StringPiece GetFilename(const StringPiece& path) { const char* end = path.end(); const char* last_dir_sep = path.begin(); for (const char* c = path.begin(); c != end; ++c) { - if (*c == sDirSep) { + if (*c == sDirSep || *c == sInvariantDirSep) { last_dir_sep = c + 1; } } diff --git a/tools/aapt2/util/Files.h b/tools/aapt2/util/Files.h index 481a4cdb6ad09..e50cb505bf668 100644 --- a/tools/aapt2/util/Files.h +++ b/tools/aapt2/util/Files.h @@ -41,6 +41,8 @@ constexpr const char sDirSep = '/'; constexpr const char sPathSep = ':'; #endif +constexpr const char sInvariantDirSep = '/'; + enum class FileType { kUnknown = 0, kNonexistant,