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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 int result = NO_RETRY_EXPECTED(mkdir(dir_name, 0777)); | 396 int result = NO_RETRY_EXPECTED(mkdir(dir_name, 0777)); |
397 // If the directory already exists, treat it as a success. | 397 // If the directory already exists, treat it as a success. |
398 if ((result == -1) && (errno == EEXIST)) { | 398 if ((result == -1) && (errno == EEXIST)) { |
399 return (Exists(dir_name) == EXISTS); | 399 return (Exists(dir_name) == EXISTS); |
400 } | 400 } |
401 return (result == 0); | 401 return (result == 0); |
402 } | 402 } |
403 | 403 |
404 | 404 |
405 const char* Directory::SystemTemp() { | 405 const char* Directory::SystemTemp() { |
406 if (Directory::system_temp_path_override_ != NULL) { | |
407 return DartUtils::ScopedCopyCString(Directory::system_temp_path_override_); | |
408 } | |
406 // Android does not have a /tmp directory. A partial substitute, | 409 // Android does not have a /tmp directory. A partial substitute, |
407 // suitable for bring-up work and tests, is to create a tmp | 410 // suitable for bring-up work and tests, is to create a tmp |
408 // directory in /data/local/tmp. | 411 // directory in /data/local/tmp. |
409 // | 412 // |
410 // TODO(4413): In the long run, when running in an application we should | 413 // TODO(4413): In the long run, when running in an application we should |
rmacnak
2016/07/18 17:41:49
I'd reference this issue in the commit message.
Cutch
2016/07/18 17:44:58
Done.
| |
411 // probably use the appropriate directory from the Android API, | 414 // probably use the appropriate directory from the Android API, |
412 // probably what File.createTempFile uses. | 415 // probably what File.createTempFile uses. |
413 #define ANDROID_TEMP_DIR "/data/local/tmp" | 416 #define ANDROID_TEMP_DIR "/data/local/tmp" |
414 struct stat st; | 417 struct stat st; |
415 if (stat(ANDROID_TEMP_DIR, &st) != 0) { | 418 if (stat(ANDROID_TEMP_DIR, &st) != 0) { |
416 mkdir(ANDROID_TEMP_DIR, 0777); | 419 mkdir(ANDROID_TEMP_DIR, 0777); |
417 } | 420 } |
418 return ANDROID_TEMP_DIR; | 421 return ANDROID_TEMP_DIR; |
419 } | 422 } |
420 | 423 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
465 if (exists != EXISTS) { | 468 if (exists != EXISTS) { |
466 return false; | 469 return false; |
467 } | 470 } |
468 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0); | 471 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0); |
469 } | 472 } |
470 | 473 |
471 } // namespace bin | 474 } // namespace bin |
472 } // namespace dart | 475 } // namespace dart |
473 | 476 |
474 #endif // defined(TARGET_OS_ANDROID) | 477 #endif // defined(TARGET_OS_ANDROID) |
OLD | NEW |