| 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 if (result == -1) { | 247 if (result == -1) { |
| 248 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno)); | 248 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno)); |
| 249 } | 249 } |
| 250 if (S_ISCHR(buf.st_mode)) return kTerminal; | 250 if (S_ISCHR(buf.st_mode)) return kTerminal; |
| 251 if (S_ISFIFO(buf.st_mode)) return kPipe; | 251 if (S_ISFIFO(buf.st_mode)) return kPipe; |
| 252 if (S_ISSOCK(buf.st_mode)) return kSocket; | 252 if (S_ISSOCK(buf.st_mode)) return kSocket; |
| 253 if (S_ISREG(buf.st_mode)) return kFile; | 253 if (S_ISREG(buf.st_mode)) return kFile; |
| 254 return kOther; | 254 return kOther; |
| 255 } | 255 } |
| 256 | 256 |
| 257 |
| 258 File::Type File::GetType(const char* pathname, bool follow_links) { |
| 259 struct stat entry_info; |
| 260 int stat_success; |
| 261 if (follow_links) { |
| 262 stat_success = TEMP_FAILURE_RETRY(stat(pathname, &entry_info)); |
| 263 } else { |
| 264 stat_success = TEMP_FAILURE_RETRY(lstat(pathname, &entry_info)); |
| 265 } |
| 266 if (stat_success == -1) return File::kDoesNotExist; |
| 267 if (S_ISDIR(entry_info.st_mode)) return File::kIsDirectory; |
| 268 if (S_ISREG(entry_info.st_mode)) return File::kIsFile; |
| 269 if (S_ISLNK(entry_info.st_mode)) return File::kIsLink; |
| 270 return File::kDoesNotExist; |
| 271 } |
| 272 |
| 257 #endif // defined(TARGET_OS_MACOS) | 273 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |