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