| 225 | } |
| 226 | |
| 227 | size_t TDirectIOBufferedFile::Pread(void* buffer, size_t byteCount, ui64 offset) { |
| 228 | if (!byteCount) { |
| 229 | return 0; |
| 230 | } |
| 231 | |
| 232 | size_t readFromFile = 0; |
| 233 | if (offset < FlushedBytes) { |
| 234 | readFromFile = Min<ui64>(byteCount, FlushedBytes - offset); |
| 235 | size_t bytesRead = ReadFromFile(buffer, readFromFile, offset); |
| 236 | if (bytesRead != readFromFile || readFromFile == byteCount) { |
| 237 | return bytesRead; |
| 238 | } |
| 239 | } |
| 240 | ui64 start = offset > FlushedBytes ? offset - FlushedBytes : 0; |
| 241 | ui64 count = Min<ui64>(DataLen - start, byteCount - readFromFile); |
| 242 | if (count) { |
| 243 | memcpy((char*)buffer + readFromFile, (const char*)Buffer + start, count); |
| 244 | } |
| 245 | return count + readFromFile; |
| 246 | } |
| 247 | |
| 248 | void TDirectIOBufferedFile::Pwrite(const void* buffer, size_t byteCount, ui64 offset) { |
| 249 | if (offset > WritePosition) { |
no test coverage detected