| 331 | } |
| 332 | |
| 333 | Result<int64_t> ValidateReadRange(int64_t offset, int64_t size, int64_t file_size) { |
| 334 | if (offset < 0 || size < 0) { |
| 335 | return Status::Invalid("Invalid read (offset = ", offset, ", size = ", size, ")"); |
| 336 | } |
| 337 | if (offset > file_size) { |
| 338 | return Status::IOError("Read out of bounds (offset = ", offset, ", size = ", size, |
| 339 | ") in file of size ", file_size); |
| 340 | } |
| 341 | return std::min(size, file_size - offset); |
| 342 | } |
| 343 | |
| 344 | Status ValidateWriteRange(int64_t offset, int64_t size, int64_t file_size) { |
| 345 | if (offset < 0 || size < 0) { |