| 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_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
| 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 } | 353 } |
| 354 | 354 |
| 355 | 355 |
| 356 Directory::ExistsResult Directory::Exists(const char* dir_name) { | 356 Directory::ExistsResult Directory::Exists(const char* dir_name) { |
| 357 struct stat64 entry_info; | 357 struct stat64 entry_info; |
| 358 int success = TEMP_FAILURE_RETRY(stat64(dir_name, &entry_info)); | 358 int success = TEMP_FAILURE_RETRY(stat64(dir_name, &entry_info)); |
| 359 if (success == 0) { | 359 if (success == 0) { |
| 360 if (S_ISDIR(entry_info.st_mode)) { | 360 if (S_ISDIR(entry_info.st_mode)) { |
| 361 return EXISTS; | 361 return EXISTS; |
| 362 } else { | 362 } else { |
| 363 // An OSError may be constructed based on the return value of this |
| 364 // function, so set errno to something that makes sense. |
| 365 errno = ENOENT; |
| 363 return DOES_NOT_EXIST; | 366 return DOES_NOT_EXIST; |
| 364 } | 367 } |
| 365 } else { | 368 } else { |
| 366 if ((errno == EACCES) || (errno == EBADF) || (errno == EFAULT) || | 369 if ((errno == EACCES) || (errno == EBADF) || (errno == EFAULT) || |
| 367 (errno == ENOMEM) || (errno == EOVERFLOW)) { | 370 (errno == ENOMEM) || (errno == EOVERFLOW)) { |
| 368 // Search permissions denied for one of the directories in the | 371 // Search permissions denied for one of the directories in the |
| 369 // path or a low level error occured. We do not know if the | 372 // path or a low level error occured. We do not know if the |
| 370 // directory exists. | 373 // directory exists. |
| 371 return UNKNOWN; | 374 return UNKNOWN; |
| 372 } | 375 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 if (exists != EXISTS) { | 480 if (exists != EXISTS) { |
| 478 return false; | 481 return false; |
| 479 } | 482 } |
| 480 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0); | 483 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0); |
| 481 } | 484 } |
| 482 | 485 |
| 483 } // namespace bin | 486 } // namespace bin |
| 484 } // namespace dart | 487 } // namespace dart |
| 485 | 488 |
| 486 #endif // defined(TARGET_OS_LINUX) | 489 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |