| 116 | #endif |
| 117 | } |
| 118 | size_t FileStream::read_some(void *data, size_t size) { |
| 119 | size = std::min(size, MAX_CHUNK); // Some oses cannot read more than 2 gb at once |
| 120 | #ifdef _WIN32 |
| 121 | DWORD si = 0; |
| 122 | if (!ReadFile(handle, data, static_cast<DWORD>(size), &si, nullptr)) |
| 123 | throw common::StreamError("Error reading file, GetLastError()=" + common::to_string(GetLastError())); |
| 124 | return si; |
| 125 | #else |
| 126 | ssize_t si = ::read(fd, data, size); |
| 127 | if (si == -1) |
| 128 | throw common::StreamError("Error reading file, errno=" + common::to_string(errno)); |
| 129 | return (size_t)si; |
| 130 | #endif |
| 131 | } |
| 132 | |
| 133 | void FileStream::fsync() { |
| 134 | #ifdef _WIN32 |
no test coverage detected