| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 #if defined(TARGET_OS_ANDROID) | 6 #if defined(TARGET_OS_ANDROID) |
| 7 | 7 |
| 8 #include "bin/directory.h" | 8 #include "bin/directory.h" |
| 9 | 9 |
| 10 #include <dirent.h> // NOLINT | 10 #include <dirent.h> // NOLINT |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 // suitable for bring-up work and tests, is to create a tmp | 471 // suitable for bring-up work and tests, is to create a tmp |
| 472 // directory in /data/local/tmp. | 472 // directory in /data/local/tmp. |
| 473 // | 473 // |
| 474 // TODO(4413): In the long run, when running in an application we should | 474 // TODO(4413): In the long run, when running in an application we should |
| 475 // probably use android.content.Context.getCacheDir(). | 475 // probably use android.content.Context.getCacheDir(). |
| 476 #define ANDROID_TEMP_DIR "/data/local/tmp" | 476 #define ANDROID_TEMP_DIR "/data/local/tmp" |
| 477 struct stat st; | 477 struct stat st; |
| 478 if (stat(ANDROID_TEMP_DIR, &st) != 0) { | 478 if (stat(ANDROID_TEMP_DIR, &st) != 0) { |
| 479 mkdir(ANDROID_TEMP_DIR, 0777); | 479 mkdir(ANDROID_TEMP_DIR, 0777); |
| 480 } | 480 } |
| 481 path.Add(ANDROID_TEMP_DIR "/tmp/temp_dir1_"); | 481 path.Add(ANDROID_TEMP_DIR "/temp_dir1_"); |
| 482 } else if ((path.data)[path.length - 1] == '/') { | 482 } else if ((path.data)[path.length - 1] == '/') { |
| 483 path.Add("temp_dir_"); | 483 path.Add("temp_dir_"); |
| 484 } | 484 } |
| 485 if (!path.Add("XXXXXX")) { | 485 if (!path.Add("XXXXXX")) { |
| 486 // Pattern has overflowed. | 486 // Pattern has overflowed. |
| 487 return NULL; | 487 return NULL; |
| 488 } | 488 } |
| 489 char* result; | 489 char* result; |
| 490 do { | 490 do { |
| 491 result = MakeTempDirectory(path.data); | 491 result = MakeTempDirectory(path.data); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 521 bool Directory::Rename(const char* path, const char* new_path) { | 521 bool Directory::Rename(const char* path, const char* new_path) { |
| 522 ExistsResult exists = Exists(path); | 522 ExistsResult exists = Exists(path); |
| 523 if (exists != EXISTS) return false; | 523 if (exists != EXISTS) return false; |
| 524 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0); | 524 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0); |
| 525 } | 525 } |
| 526 | 526 |
| 527 } // namespace bin | 527 } // namespace bin |
| 528 } // namespace dart | 528 } // namespace dart |
| 529 | 529 |
| 530 #endif // defined(TARGET_OS_ANDROID) | 530 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |