From e5fed03772144595c0904faf3d6974cc55214c8c Mon Sep 17 00:00:00 2001 From: Richard Uhler Date: Wed, 18 Mar 2015 08:21:11 -0700 Subject: Support relative encoded dex locations in oat files. Now when opening an oat file, the caller can pass an absolute dex location used to resolve the absolute path for any relative encoded dex locations in the oat file. Bug: 19550105 Change-Id: I6e9559afe4d86ac12cf0b90176b5ea696a83d0e7 --- runtime/dex_file.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'runtime/dex_file.h') diff --git a/runtime/dex_file.h b/runtime/dex_file.h index c8ede48..da39573 100644 --- a/runtime/dex_file.h +++ b/runtime/dex_file.h @@ -421,15 +421,26 @@ class DexFile { } } - std::string GetBaseLocation() const { - size_t pos = location_.rfind(kMultiDexSeparator); + static std::string GetBaseLocation(const std::string& location) { + return GetBaseLocation(location.c_str()); + } + + // Returns the ':classes*.dex' part of the dex location. Returns an empty + // string if there is no multidex suffix for the given location. + // The kMultiDexSeparator is included in the returned suffix. + static std::string GetMultiDexSuffix(const std::string& location) { + size_t pos = location.rfind(kMultiDexSeparator); if (pos == std::string::npos) { - return location_; + return ""; } else { - return location_.substr(0, pos); + return location.substr(pos); } } + std::string GetBaseLocation() const { + return GetBaseLocation(location_); + } + // For DexFiles directly from .dex files, this is the checksum from the DexFile::Header. // For DexFiles opened from a zip files, this will be the ZipEntry CRC32 of classes.dex. uint32_t GetLocationChecksum() const { -- cgit v1.1