| 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 break; | 222 break; |
| 223 } | 223 } |
| 224 if (S_ISDIR(entry_info.st_mode)) { | 224 if (S_ISDIR(entry_info.st_mode)) { |
| 225 // Recurse into the subdirectory with current_link added to the | 225 // Recurse into the subdirectory with current_link added to the |
| 226 // linked list of seen file system links. | 226 // linked list of seen file system links. |
| 227 path->Reset(path_length); | 227 path->Reset(path_length); |
| 228 success = HandleDir(entry.d_name, | 228 success = HandleDir(entry.d_name, |
| 229 path, | 229 path, |
| 230 recursive, | 230 recursive, |
| 231 follow_links, | 231 follow_links, |
| 232 seen, | |
| 233 ¤t_link, | 232 ¤t_link, |
| 234 listing) && success; | 233 listing) && success; |
| 235 break; | 234 break; |
| 236 } | 235 } |
| 237 } | 236 } |
| 238 path->Reset(path_length); | 237 path->Reset(path_length); |
| 239 if (S_ISDIR(entry_info.st_mode)) { | 238 if (S_ISDIR(entry_info.st_mode)) { |
| 240 success = HandleDir(entry.d_name, | 239 success = HandleDir(entry.d_name, |
| 241 path, | 240 path, |
| 242 recursive, | 241 recursive, |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 // 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 |
| 473 // directory in /data/local/tmp. | 472 // directory in /data/local/tmp. |
| 474 // | 473 // |
| 475 // 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 |
| 476 // probably use android.content.Context.getCacheDir(). | 475 // probably use android.content.Context.getCacheDir(). |
| 477 #define ANDROID_TEMP_DIR "/data/local/tmp" | 476 #define ANDROID_TEMP_DIR "/data/local/tmp" |
| 478 struct stat st; | 477 struct stat st; |
| 479 if (stat(ANDROID_TEMP_DIR, &st) != 0) { | 478 if (stat(ANDROID_TEMP_DIR, &st) != 0) { |
| 480 mkdir(ANDROID_TEMP_DIR, 0777); | 479 mkdir(ANDROID_TEMP_DIR, 0777); |
| 481 } | 480 } |
| 482 path->Add(ANDROID_TEMP_DIR "/tmp/temp_dir1_"); | 481 path.Add(ANDROID_TEMP_DIR "/tmp/temp_dir1_"); |
| 483 } else if ((path.data)[path.length - 1] == '/') { | 482 } else if ((path.data)[path.length - 1] == '/') { |
| 484 path.Add("temp_dir_"); | 483 path.Add("temp_dir_"); |
| 485 } | 484 } |
| 486 if (!path.Add("XXXXXX")) { | 485 if (!path.Add("XXXXXX")) { |
| 487 // Pattern has overflowed. | 486 // Pattern has overflowed. |
| 488 return NULL; | 487 return NULL; |
| 489 } | 488 } |
| 490 char* result; | 489 char* result; |
| 491 do { | 490 do { |
| 492 result = MakeTempDirectory(path->data); | 491 result = MakeTempDirectory(path.data); |
| 493 } while (result == NULL && errno == EINTR); | 492 } while (result == NULL && errno == EINTR); |
| 494 if (result == NULL) { | 493 if (result == NULL) { |
| 495 return NULL; | 494 return NULL; |
| 496 } | 495 } |
| 497 int length = strnlen(path.data, PATH_MAX); | 496 int length = strnlen(path.data, PATH_MAX); |
| 498 result = static_cast<char*>(malloc(length + 1)); | 497 result = static_cast<char*>(malloc(length + 1)); |
| 499 strncpy(result, path.data, length); | 498 strncpy(result, path.data, length); |
| 500 result[length] = '\0'; | 499 result[length] = '\0'; |
| 501 return result; | 500 return result; |
| 502 } | 501 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 522 bool Directory::Rename(const char* path, const char* new_path) { | 521 bool Directory::Rename(const char* path, const char* new_path) { |
| 523 ExistsResult exists = Exists(path); | 522 ExistsResult exists = Exists(path); |
| 524 if (exists != EXISTS) return false; | 523 if (exists != EXISTS) return false; |
| 525 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0); | 524 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0); |
| 526 } | 525 } |
| 527 | 526 |
| 528 } // namespace bin | 527 } // namespace bin |
| 529 } // namespace dart | 528 } // namespace dart |
| 530 | 529 |
| 531 #endif // defined(TARGET_OS_ANDROID) | 530 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |