| 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/file.h" | 8 #include "bin/file.h" |
| 9 | 9 |
| 10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 bool File::Create(const char* name) { | 155 bool File::Create(const char* name) { |
| 156 int fd = TEMP_FAILURE_RETRY(open(name, O_RDONLY | O_CREAT, 0666)); | 156 int fd = TEMP_FAILURE_RETRY(open(name, O_RDONLY | O_CREAT, 0666)); |
| 157 if (fd < 0) { | 157 if (fd < 0) { |
| 158 return false; | 158 return false; |
| 159 } | 159 } |
| 160 return (close(fd) == 0); | 160 return (close(fd) == 0); |
| 161 } | 161 } |
| 162 | 162 |
| 163 | 163 |
| 164 bool File::CreateLink(const char* name, const char* target) { |
| 165 int status = TEMP_FAILURE_RETRY(symlink(target, name)); |
| 166 return (status == 0); |
| 167 } |
| 168 |
| 169 |
| 164 bool File::Delete(const char* name) { | 170 bool File::Delete(const char* name) { |
| 165 int status = TEMP_FAILURE_RETRY(remove(name)); | 171 int status = TEMP_FAILURE_RETRY(remove(name)); |
| 166 if (status == -1) { | 172 if (status == -1) { |
| 167 return false; | 173 return false; |
| 168 } | 174 } |
| 169 return true; | 175 return true; |
| 170 } | 176 } |
| 171 | 177 |
| 172 | 178 |
| 173 off_t File::LengthFromPath(const char* name) { | 179 off_t File::LengthFromPath(const char* name) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 stat_success = TEMP_FAILURE_RETRY(lstat(pathname, &entry_info)); | 270 stat_success = TEMP_FAILURE_RETRY(lstat(pathname, &entry_info)); |
| 265 } | 271 } |
| 266 if (stat_success == -1) return File::kDoesNotExist; | 272 if (stat_success == -1) return File::kDoesNotExist; |
| 267 if (S_ISDIR(entry_info.st_mode)) return File::kIsDirectory; | 273 if (S_ISDIR(entry_info.st_mode)) return File::kIsDirectory; |
| 268 if (S_ISREG(entry_info.st_mode)) return File::kIsFile; | 274 if (S_ISREG(entry_info.st_mode)) return File::kIsFile; |
| 269 if (S_ISLNK(entry_info.st_mode)) return File::kIsLink; | 275 if (S_ISLNK(entry_info.st_mode)) return File::kIsLink; |
| 270 return File::kDoesNotExist; | 276 return File::kDoesNotExist; |
| 271 } | 277 } |
| 272 | 278 |
| 273 #endif // defined(TARGET_OS_MACOS) | 279 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |