diff options
author | Michael Roizner <mroizner@gmail.com> | 2022-02-10 16:50:47 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:47 +0300 |
commit | 4e10711f67db90b5b08220fee274f8f0fe620485 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /util/system/file.cpp | |
parent | a196186fa7feb0aae6d87e1b6d890a83851be4f2 (diff) | |
download | ydb-4e10711f67db90b5b08220fee274f8f0fe620485.tar.gz |
Restoring authorship annotation for Michael Roizner <mroizner@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'util/system/file.cpp')
-rw-r--r-- | util/system/file.cpp | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/util/system/file.cpp b/util/system/file.cpp index d6d7d05062..4a261d020c 100644 --- a/util/system/file.cpp +++ b/util/system/file.cpp @@ -339,25 +339,25 @@ bool TFileHandle::Resize(i64 length) noexcept { if (!IsOpen()) { return false; } - i64 currentLength = GetLength(); + i64 currentLength = GetLength(); if (length == currentLength) { - return true; + return true; } #if defined(_win_) - i64 currentPosition = GetPosition(); + i64 currentPosition = GetPosition(); if (currentPosition == -1L) { return false; } - Seek(length, sSet); + Seek(length, sSet); if (!::SetEndOfFile(Fd_)) { return false; } if (currentPosition < length) { - Seek(currentPosition, sSet); + Seek(currentPosition, sSet); } return true; #elif defined(_unix_) - return (0 == ftruncate(Fd_, (off_t)length)); + return (0 == ftruncate(Fd_, (off_t)length)); #else #error unsupported platform #endif @@ -366,28 +366,28 @@ bool TFileHandle::Resize(i64 length) noexcept { bool TFileHandle::Reserve(i64 length) noexcept { // FIXME this should reserve disk space with fallocate if (!IsOpen()) { - return false; + return false; } - i64 currentLength = GetLength(); + i64 currentLength = GetLength(); if (length <= currentLength) { - return true; + return true; } if (!Resize(length)) { - return false; + return false; } #if defined(_win_) - if (!::SetFileValidData(Fd_, length)) { - Resize(currentLength); - return false; - } + if (!::SetFileValidData(Fd_, length)) { + Resize(currentLength); + return false; + } #elif defined(_unix_) // No way to implement this under FreeBSD. Just do nothing -#else +#else #error unsupported platform -#endif - return true; -} - +#endif + return true; +} + bool TFileHandle::FallocateNoResize(i64 length) noexcept { if (!IsOpen()) { return false; @@ -897,7 +897,7 @@ public: ythrow TFileError() << "can't reserve " << length << " for file " << FileName_.Quote(); } } - + void FallocateNoResize(i64 length) { if (!Handle_.FallocateNoResize(length)) { ythrow TFileError() << "can't allocate " << length << "bytes of space for file " << FileName_.Quote(); @@ -1137,14 +1137,14 @@ i64 TFile::Seek(i64 offset, SeekDir origin) { return Impl_->Seek(offset, origin); } -void TFile::Resize(i64 length) { - Impl_->Resize(length); +void TFile::Resize(i64 length) { + Impl_->Resize(length); +} + +void TFile::Reserve(i64 length) { + Impl_->Reserve(length); } -void TFile::Reserve(i64 length) { - Impl_->Reserve(length); -} - void TFile::FallocateNoResize(i64 length) { Impl_->FallocateNoResize(length); } |