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_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 return DOES_NOT_EXIST; | 413 return DOES_NOT_EXIST; |
414 } | 414 } |
415 } | 415 } |
416 | 416 |
417 | 417 |
418 char* Directory::Current() { | 418 char* Directory::Current() { |
419 return getcwd(NULL, 0); | 419 return getcwd(NULL, 0); |
420 } | 420 } |
421 | 421 |
422 | 422 |
| 423 bool Directory::SetCurrent(const char* path) { |
| 424 int result = TEMP_FAILURE_RETRY(chdir(path)); |
| 425 return result == 0; |
| 426 } |
| 427 |
| 428 |
423 bool Directory::Create(const char* dir_name) { | 429 bool Directory::Create(const char* dir_name) { |
424 // Create the directory with the permissions specified by the | 430 // Create the directory with the permissions specified by the |
425 // process umask. | 431 // process umask. |
426 int result = TEMP_FAILURE_RETRY(mkdir(dir_name, 0777)); | 432 int result = TEMP_FAILURE_RETRY(mkdir(dir_name, 0777)); |
427 // If the directory already exists, treat it as a success. | 433 // If the directory already exists, treat it as a success. |
428 if (result == -1 && errno == EEXIST) { | 434 if (result == -1 && errno == EEXIST) { |
429 return (Exists(dir_name) == EXISTS); | 435 return (Exists(dir_name) == EXISTS); |
430 } | 436 } |
431 return (result == 0); | 437 return (result == 0); |
432 } | 438 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 bool Directory::Rename(const char* path, const char* new_path) { | 489 bool Directory::Rename(const char* path, const char* new_path) { |
484 ExistsResult exists = Exists(path); | 490 ExistsResult exists = Exists(path); |
485 if (exists != EXISTS) return false; | 491 if (exists != EXISTS) return false; |
486 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0); | 492 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0); |
487 } | 493 } |
488 | 494 |
489 } // namespace bin | 495 } // namespace bin |
490 } // namespace dart | 496 } // namespace dart |
491 | 497 |
492 #endif // defined(TARGET_OS_MACOS) | 498 #endif // defined(TARGET_OS_MACOS) |
OLD | NEW |