| Index: runtime/bin/directory_android.cc
|
| diff --git a/runtime/bin/directory_android.cc b/runtime/bin/directory_android.cc
|
| index b48474d16c182afd02c165420c380c930d32c5be..6a2646a06ce01d6f9cee9444406f005265b643e3 100644
|
| --- a/runtime/bin/directory_android.cc
|
| +++ b/runtime/bin/directory_android.cc
|
| @@ -382,33 +382,34 @@ static char* MakeTempDirectory(char* path_template) {
|
| }
|
|
|
|
|
| -char* Directory::CreateTemp(const char* const_template) {
|
| +char* Directory::CreateTemp(const char* const_template, bool system) {
|
| // Returns a new, unused directory name, modifying the contents of
|
| // dir_template. Creates the directory with the permissions specified
|
| // by the process umask.
|
| // The return value must be freed by the caller.
|
| PathBuffer path;
|
| - path.Add(const_template);
|
| - if (path.length() == 0) {
|
| + if (system) {
|
| // Android does not have a /tmp directory. A partial substitute,
|
| // suitable for bring-up work and tests, is to create a tmp
|
| // directory in /data/local/tmp.
|
| //
|
| // TODO(4413): In the long run, when running in an application we should
|
| - // probably use android.content.Context.getCacheDir().
|
| + // probably use the appropriate directory from the Android API,
|
| + // probably what File.createTempFile uses.
|
| #define ANDROID_TEMP_DIR "/data/local/tmp"
|
| struct stat st;
|
| if (stat(ANDROID_TEMP_DIR, &st) != 0) {
|
| mkdir(ANDROID_TEMP_DIR, 0777);
|
| }
|
| - path.Add(ANDROID_TEMP_DIR "/temp_dir1_");
|
| - } else if ((path.AsString())[path.length() - 1] == '/') {
|
| - path.Add("temp_dir_");
|
| + path.Add(ANDROID_TEMP_DIR "/");
|
| }
|
| +
|
| + path.Add(const_template);
|
| if (!path.Add("XXXXXX")) {
|
| // Pattern has overflowed.
|
| return NULL;
|
| }
|
| +
|
| char* result;
|
| do {
|
| result = MakeTempDirectory(path.AsString());
|
|
|