| 51 | |
| 52 | |
| 53 | Future<size_t> read(int_fd fd, void* data, size_t size) |
| 54 | { |
| 55 | process::initialize(); |
| 56 | |
| 57 | // Check the file descriptor. |
| 58 | Try<bool> async = is_async(fd); |
| 59 | if (async.isError()) { |
| 60 | // The file descriptor is not valid (e.g., has been closed). |
| 61 | return Failure( |
| 62 | "Failed to check if file descriptor was asynchronous: " + |
| 63 | async.error()); |
| 64 | } else if (!async.get()) { |
| 65 | return Failure("Expected an asynchronous file descriptor."); |
| 66 | } |
| 67 | |
| 68 | #ifndef ENABLE_LIBWINIO |
| 69 | return internal::read(fd, data, size); |
| 70 | #else |
| 71 | return internal::read(fd, data, size, true); |
| 72 | #endif // ENABLE_LIBWINIO |
| 73 | } |
| 74 | |
| 75 | |
| 76 | Future<size_t> write(int_fd fd, const void* data, size_t size) |