Clean up use of GetDalvikCache.
Switch the only caller of the non-void version of GetDalvikCache that set
create_if_absent true to use the void version of GetDalvikCache. Then no
callers of the non-void version of GetDalvikCache set create_if_absent to
true, so that argument is no longer needed. And without create_if_absent,
there is no case when the function will abort, so the 'OrDie" option is no
longer necessary.
Change-Id: I83f60dcc8a8f3b1f91fd2971e9028f6a7dd8384d
Test: m art-test-host
Test: m art-test-target
diff --git a/runtime/utils.cc b/runtime/utils.cc
index 515ba9f..8ab8cd2 100644
--- a/runtime/utils.cc
+++ b/runtime/utils.cc
@@ -1087,58 +1087,18 @@
}
}
-static std::string GetDalvikCacheImpl(const char* subdir,
- const bool create_if_absent,
- const bool abort_on_error) {
+std::string GetDalvikCache(const char* subdir) {
CHECK(subdir != nullptr);
const char* android_data = GetAndroidData();
const std::string dalvik_cache_root(StringPrintf("%s/dalvik-cache/", android_data));
const std::string dalvik_cache = dalvik_cache_root + subdir;
if (!OS::DirectoryExists(dalvik_cache.c_str())) {
- if (!create_if_absent) {
- // TODO: Check callers. Traditional behavior is to not to abort, even when abort_on_error.
- return "";
- }
-
- // Don't create the system's /data/dalvik-cache/... because it needs special permissions.
- if (strcmp(android_data, "/data") == 0) {
- if (abort_on_error) {
- LOG(FATAL) << "Failed to find dalvik-cache directory " << dalvik_cache
- << ", cannot create /data dalvik-cache.";
- UNREACHABLE();
- }
- return "";
- }
-
- int result = mkdir(dalvik_cache_root.c_str(), 0700);
- if (result != 0 && errno != EEXIST) {
- if (abort_on_error) {
- PLOG(FATAL) << "Failed to create dalvik-cache root directory " << dalvik_cache_root;
- UNREACHABLE();
- }
- return "";
- }
-
- result = mkdir(dalvik_cache.c_str(), 0700);
- if (result != 0) {
- if (abort_on_error) {
- PLOG(FATAL) << "Failed to create dalvik-cache directory " << dalvik_cache;
- UNREACHABLE();
- }
- return "";
- }
+ // TODO: Check callers. Traditional behavior is to not abort.
+ return "";
}
return dalvik_cache;
}
-std::string GetDalvikCache(const char* subdir, const bool create_if_absent) {
- return GetDalvikCacheImpl(subdir, create_if_absent, false);
-}
-
-std::string GetDalvikCacheOrDie(const char* subdir, const bool create_if_absent) {
- return GetDalvikCacheImpl(subdir, create_if_absent, true);
-}
-
bool GetDalvikCacheFilename(const char* location, const char* cache_location,
std::string* filename, std::string* error_msg) {
if (location[0] != '/') {