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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 bool PathBuffer::Add(const char* name) { | 43 bool PathBuffer::Add(const char* name) { |
44 char* data = AsString(); | 44 char* data = AsString(); |
45 int written = snprintf(data + length_, | 45 int written = snprintf(data + length_, |
46 PATH_MAX - length_, | 46 PATH_MAX - length_, |
47 "%s", | 47 "%s", |
48 name); | 48 name); |
49 data[PATH_MAX] = '\0'; | 49 data[PATH_MAX] = '\0'; |
50 if (written <= PATH_MAX - length_ && | 50 if (written <= PATH_MAX - length_ && |
51 written >= 0 && | 51 written >= 0 && |
52 static_cast<size_t>(written) == strnlen(name, PATH_MAX + 1)) { | 52 static_cast<size_t>(written) == strlen(name)) { |
53 length_ += written; | 53 length_ += written; |
54 return true; | 54 return true; |
55 } else { | 55 } else { |
56 errno = ENAMETOOLONG; | 56 errno = ENAMETOOLONG; |
57 return false; | 57 return false; |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 void PathBuffer::Reset(int new_length) { | 61 void PathBuffer::Reset(int new_length) { |
62 length_ = new_length; | 62 length_ = new_length; |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 bool Directory::Rename(const char* path, const char* new_path) { | 401 bool Directory::Rename(const char* path, const char* new_path) { |
402 ExistsResult exists = Exists(path); | 402 ExistsResult exists = Exists(path); |
403 if (exists != EXISTS) return false; | 403 if (exists != EXISTS) return false; |
404 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0); | 404 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0); |
405 } | 405 } |
406 | 406 |
407 } // namespace bin | 407 } // namespace bin |
408 } // namespace dart | 408 } // namespace dart |
409 | 409 |
410 #endif // defined(TARGET_OS_MACOS) | 410 #endif // defined(TARGET_OS_MACOS) |
OLD | NEW |