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" |
| 6 #if defined(TARGET_OS_MACOS) |
| 7 |
5 #include "bin/file.h" | 8 #include "bin/file.h" |
6 | 9 |
7 #include <errno.h> | 10 #include <errno.h> // NOLINT |
8 #include <fcntl.h> | 11 #include <fcntl.h> // NOLINT |
9 #include <sys/stat.h> | 12 #include <sys/stat.h> // NOLINT |
10 #include <unistd.h> | 13 #include <unistd.h> // NOLINT |
11 #include <libgen.h> | 14 #include <libgen.h> // NOLINT |
12 #include <limits.h> | 15 #include <limits.h> // NOLINT |
13 | 16 |
14 #include "bin/builtin.h" | 17 #include "bin/builtin.h" |
15 #include "bin/fdutils.h" | 18 #include "bin/fdutils.h" |
16 #include "bin/log.h" | 19 #include "bin/log.h" |
17 | 20 |
18 class FileHandle { | 21 class FileHandle { |
19 public: | 22 public: |
20 explicit FileHandle(int fd) : fd_(fd) { } | 23 explicit FileHandle(int fd) : fd_(fd) { } |
21 ~FileHandle() { } | 24 ~FileHandle() { } |
22 int fd() const { return fd_; } | 25 int fd() const { return fd_; } |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 int result = fstat(fd, &buf); | 246 int result = fstat(fd, &buf); |
244 if (result == -1) { | 247 if (result == -1) { |
245 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno)); | 248 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno)); |
246 } | 249 } |
247 if (S_ISCHR(buf.st_mode)) return kTerminal; | 250 if (S_ISCHR(buf.st_mode)) return kTerminal; |
248 if (S_ISFIFO(buf.st_mode)) return kPipe; | 251 if (S_ISFIFO(buf.st_mode)) return kPipe; |
249 if (S_ISSOCK(buf.st_mode)) return kSocket; | 252 if (S_ISSOCK(buf.st_mode)) return kSocket; |
250 if (S_ISREG(buf.st_mode)) return kFile; | 253 if (S_ISREG(buf.st_mode)) return kFile; |
251 return kOther; | 254 return kOther; |
252 } | 255 } |
| 256 |
| 257 #endif // defined(TARGET_OS_MACOS) |
OLD | NEW |