| 1687 | } |
| 1688 | |
| 1689 | Result<int64_t> FileReadAt(int fd, uint8_t* buffer, int64_t position, int64_t nbytes) { |
| 1690 | int64_t bytes_read = 0; |
| 1691 | |
| 1692 | while (bytes_read < nbytes) { |
| 1693 | int64_t chunksize = |
| 1694 | std::min(static_cast<int64_t>(ARROW_MAX_IO_CHUNKSIZE), nbytes - bytes_read); |
| 1695 | int64_t ret = pread_compat(fd, buffer, chunksize, position); |
| 1696 | |
| 1697 | if (ret == -1) { |
| 1698 | return IOErrorFromErrno(errno, "Error reading bytes from file"); |
| 1699 | } |
| 1700 | if (ret == 0) { |
| 1701 | // EOF |
| 1702 | break; |
| 1703 | } |
| 1704 | buffer += ret; |
| 1705 | position += ret; |
| 1706 | bytes_read += ret; |
| 1707 | } |
| 1708 | return bytes_read; |
| 1709 | } |
| 1710 | |
| 1711 | // |
| 1712 | // Writing data |
no test coverage detected