diff options
author | easergeev <easergeev@yandex-team.ru> | 2022-02-10 16:51:45 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:51:45 +0300 |
commit | 2db97242fffe2a2e7fcfb321249fbb3ade943210 (patch) | |
tree | 7704c05183f852edb43c4cc9f81b33bdf8474f9e /util/system/file.cpp | |
parent | 3288844da9a26e598b08a1f4c2362603bcf1f506 (diff) | |
download | ydb-2db97242fffe2a2e7fcfb321249fbb3ade943210.tar.gz |
Restoring authorship annotation for <easergeev@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/system/file.cpp')
-rw-r--r-- | util/system/file.cpp | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/util/system/file.cpp b/util/system/file.cpp index 4a261d020c..d857e34fd9 100644 --- a/util/system/file.cpp +++ b/util/system/file.cpp @@ -27,11 +27,11 @@ #if defined(_unix_) #include <fcntl.h> - + #if defined(_linux_) && (!defined(_android_) || __ANDROID_API__ >= 21) && !defined(FALLOC_FL_KEEP_SIZE) #include <linux/falloc.h> #endif - + #include <stdlib.h> #include <unistd.h> #include <sys/mman.h> @@ -388,30 +388,30 @@ bool TFileHandle::Reserve(i64 length) noexcept { return true; } -bool TFileHandle::FallocateNoResize(i64 length) noexcept { - if (!IsOpen()) { - return false; - } -#if defined(_linux_) && (!defined(_android_) || __ANDROID_API__ >= 21) - return !fallocate(Fd_, FALLOC_FL_KEEP_SIZE, 0, length); -#else - Y_UNUSED(length); - return true; -#endif -} - -// Pair for FallocateNoResize -bool TFileHandle::ShrinkToFit() noexcept { - if (!IsOpen()) { - return false; - } -#if defined(_linux_) && (!defined(_android_) || __ANDROID_API__ >= 21) +bool TFileHandle::FallocateNoResize(i64 length) noexcept { + if (!IsOpen()) { + return false; + } +#if defined(_linux_) && (!defined(_android_) || __ANDROID_API__ >= 21) + return !fallocate(Fd_, FALLOC_FL_KEEP_SIZE, 0, length); +#else + Y_UNUSED(length); + return true; +#endif +} + +// Pair for FallocateNoResize +bool TFileHandle::ShrinkToFit() noexcept { + if (!IsOpen()) { + return false; + } +#if defined(_linux_) && (!defined(_android_) || __ANDROID_API__ >= 21) return !ftruncate(Fd_, (off_t)GetLength()); -#else +#else return true; -#endif -} - +#endif +} + bool TFileHandle::Flush() noexcept { if (!IsOpen()) { return false; @@ -898,18 +898,18 @@ public: } } - void FallocateNoResize(i64 length) { - if (!Handle_.FallocateNoResize(length)) { - ythrow TFileError() << "can't allocate " << length << "bytes of space for file " << FileName_.Quote(); - } - } - - void ShrinkToFit() { - if (!Handle_.ShrinkToFit()) { - ythrow TFileError() << "can't shrink " << FileName_.Quote() << " to logical size"; - } - } - + void FallocateNoResize(i64 length) { + if (!Handle_.FallocateNoResize(length)) { + ythrow TFileError() << "can't allocate " << length << "bytes of space for file " << FileName_.Quote(); + } + } + + void ShrinkToFit() { + if (!Handle_.ShrinkToFit()) { + ythrow TFileError() << "can't shrink " << FileName_.Quote() << " to logical size"; + } + } + void Flush() { if (!Handle_.Flush()) { ythrow TFileError() << "can't flush " << FileName_.Quote(); @@ -1145,14 +1145,14 @@ void TFile::Reserve(i64 length) { Impl_->Reserve(length); } -void TFile::FallocateNoResize(i64 length) { - Impl_->FallocateNoResize(length); -} - -void TFile::ShrinkToFit() { - Impl_->ShrinkToFit(); -} - +void TFile::FallocateNoResize(i64 length) { + Impl_->FallocateNoResize(length); +} + +void TFile::ShrinkToFit() { + Impl_->ShrinkToFit(); +} + void TFile::Flush() { Impl_->Flush(); } |