| 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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 // Pattern has overflowed. | 386 // Pattern has overflowed. |
| 387 return NULL; | 387 return NULL; |
| 388 } | 388 } |
| 389 char* result; | 389 char* result; |
| 390 do { | 390 do { |
| 391 result = mkdtemp(path.AsString()); | 391 result = mkdtemp(path.AsString()); |
| 392 } while (result == NULL && errno == EINTR); | 392 } while (result == NULL && errno == EINTR); |
| 393 if (result == NULL) { | 393 if (result == NULL) { |
| 394 return NULL; | 394 return NULL; |
| 395 } | 395 } |
| 396 int length = strnlen(path.AsString(), PATH_MAX); | 396 int length = strlen(path.AsString()); |
| 397 result = static_cast<char*>(malloc(length + 1)); | 397 result = static_cast<char*>(malloc(length + 1)); |
| 398 strncpy(result, path.AsString(), length); | 398 strncpy(result, path.AsString(), length); |
| 399 result[length] = '\0'; | 399 result[length] = '\0'; |
| 400 return result; | 400 return result; |
| 401 } | 401 } |
| 402 | 402 |
| 403 | 403 |
| 404 bool Directory::Delete(const char* dir_name, bool recursive) { | 404 bool Directory::Delete(const char* dir_name, bool recursive) { |
| 405 if (!recursive) { | 405 if (!recursive) { |
| 406 if (File::GetType(dir_name, false) == File::kIsLink && | 406 if (File::GetType(dir_name, false) == File::kIsLink && |
| (...skipping 14 matching lines...) Expand all Loading... |
| 421 bool Directory::Rename(const char* path, const char* new_path) { | 421 bool Directory::Rename(const char* path, const char* new_path) { |
| 422 ExistsResult exists = Exists(path); | 422 ExistsResult exists = Exists(path); |
| 423 if (exists != EXISTS) return false; | 423 if (exists != EXISTS) return false; |
| 424 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0); | 424 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0); |
| 425 } | 425 } |
| 426 | 426 |
| 427 } // namespace bin | 427 } // namespace bin |
| 428 } // namespace dart | 428 } // namespace dart |
| 429 | 429 |
| 430 #endif // defined(TARGET_OS_MACOS) | 430 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |