| 416 | } |
| 417 | |
| 418 | bool TFileHandle::Reserve(i64 length) noexcept { |
| 419 | // FIXME this should reserve disk space with fallocate |
| 420 | if (!IsOpen()) { |
| 421 | return false; |
| 422 | } |
| 423 | i64 currentLength = GetLength(); |
| 424 | if (length <= currentLength) { |
| 425 | return true; |
| 426 | } |
| 427 | if (!Resize(length)) { |
| 428 | return false; |
| 429 | } |
| 430 | #if defined(_win_) |
| 431 | if (!::SetFileValidData(Fd_, length)) { |
| 432 | Resize(currentLength); |
| 433 | return false; |
| 434 | } |
| 435 | #elif defined(_unix_) |
| 436 | // No way to implement this under FreeBSD. Just do nothing |
| 437 | #else |
| 438 | #error unsupported platform |
| 439 | #endif |
| 440 | return true; |
| 441 | } |
| 442 | |
| 443 | bool TFileHandle::FallocateNoResize(i64 length) noexcept { |
| 444 | if (!IsOpen()) { |
no test coverage detected