summaryrefslogtreecommitdiff
path: root/runtime/utils.cc
diff options
context:
space:
mode:
author Richard Uhler <ruhler@google.com> 2015-03-02 15:50:08 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2015-03-02 15:50:09 +0000
commit4ab52e75c782abf19ff9ebff8d19c87ec4ec97b6 (patch)
tree182699e6f100d74902790594dc0b377999332378 /runtime/utils.cc
parent2eb5168bd9e43b80452eaee5be32c063e124886e (diff)
parent965fd02721746d4164bc40719cd53eefab37cfb3 (diff)
Merge "Don't require three-character extensions for dex locations."
Diffstat (limited to 'runtime/utils.cc')
-rw-r--r--runtime/utils.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/runtime/utils.cc b/runtime/utils.cc
index fd2f110cb2..851ecebb05 100644
--- a/runtime/utils.cc
+++ b/runtime/utils.cc
@@ -1511,14 +1511,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/<isa>/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;
}