From 965fd02721746d4164bc40719cd53eefab37cfb3 Mon Sep 17 00:00:00 2001 From: Richard Uhler Date: Thu, 26 Feb 2015 11:08:57 -0800 Subject: Don't require three-character extensions for dex locations. Bug: 19437875 Change-Id: Ib62b4c691b04f27c5d499affd5a7fd4d9f0c64f9 --- runtime/utils.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'runtime/utils.cc') diff --git a/runtime/utils.cc b/runtime/utils.cc index 6afc373f9b..d09f27a214 100644 --- a/runtime/utils.cc +++ b/runtime/utils.cc @@ -1519,14 +1519,16 @@ std::string GetSystemImageFilename(const char* location, const InstructionSet is std::string DexFilenameToOdexFilename(const std::string& location, const InstructionSet isa) { // location = /foo/bar/baz.jar // odex_location = /foo/bar//baz.odex - - CHECK_GE(location.size(), 4U) << location; // must be at least .123 std::string odex_location(location); InsertIsaDirectory(isa, &odex_location); - size_t dot_index = odex_location.size() - 3 - 1; // 3=dex or zip or apk - CHECK_EQ('.', odex_location[dot_index]) << location; + size_t dot_index = odex_location.rfind('.'); + + // The location must have an extension, otherwise it's not clear what we + // should return. + CHECK_NE(dot_index, std::string::npos) << odex_location; + CHECK_EQ(std::string::npos, odex_location.find('/', dot_index)) << odex_location; + odex_location.resize(dot_index + 1); - CHECK_EQ('.', odex_location[odex_location.size()-1]) << location << " " << odex_location; odex_location += "odex"; return odex_location; } -- cgit v1.2.3-59-g8ed1b