Chromium Code Reviews| 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 } | 344 } |
| 345 | 345 |
| 346 | 346 |
| 347 Directory::ExistsResult Directory::Exists(const char* dir_name) { | 347 Directory::ExistsResult Directory::Exists(const char* dir_name) { |
| 348 struct stat entry_info; | 348 struct stat entry_info; |
| 349 int success = NO_RETRY_EXPECTED(stat(dir_name, &entry_info)); | 349 int success = NO_RETRY_EXPECTED(stat(dir_name, &entry_info)); |
| 350 if (success == 0) { | 350 if (success == 0) { |
| 351 if (S_ISDIR(entry_info.st_mode)) { | 351 if (S_ISDIR(entry_info.st_mode)) { |
| 352 return EXISTS; | 352 return EXISTS; |
| 353 } else { | 353 } else { |
| 354 // An OSError may be constructed based on the return value of this | |
| 355 // function, so set errno to something that makes sense. | |
| 356 errno = ENOENT; | |
|
rmacnak
2016/12/17 00:06:14
Consider ENOTDIR.
zra
2016/12/17 04:58:06
Done.
| |
| 354 return DOES_NOT_EXIST; | 357 return DOES_NOT_EXIST; |
| 355 } | 358 } |
| 356 } else { | 359 } else { |
| 357 if ((errno == EACCES) || (errno == EBADF) || (errno == EFAULT) || | 360 if ((errno == EACCES) || (errno == EBADF) || (errno == EFAULT) || |
| 358 (errno == ENOMEM) || (errno == EOVERFLOW)) { | 361 (errno == ENOMEM) || (errno == EOVERFLOW)) { |
| 359 // Search permissions denied for one of the directories in the | 362 // Search permissions denied for one of the directories in the |
| 360 // path or a low level error occured. We do not know if the | 363 // path or a low level error occured. We do not know if the |
| 361 // directory exists. | 364 // directory exists. |
| 362 return UNKNOWN; | 365 return UNKNOWN; |
| 363 } | 366 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 473 if (exists != EXISTS) { | 476 if (exists != EXISTS) { |
| 474 return false; | 477 return false; |
| 475 } | 478 } |
| 476 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0); | 479 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0); |
| 477 } | 480 } |
| 478 | 481 |
| 479 } // namespace bin | 482 } // namespace bin |
| 480 } // namespace dart | 483 } // namespace dart |
| 481 | 484 |
| 482 #endif // defined(TARGET_OS_ANDROID) | 485 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |