MCPcopy Create free account
hub / github.com/catboost/catboost / Resize

Method Resize

util/system/file.cpp:390–416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

388}
389
390bool TFileHandle::Resize(i64 length) noexcept {
391 if (!IsOpen()) {
392 return false;
393 }
394 i64 currentLength = GetLength();
395 if (length == currentLength) {
396 return true;
397 }
398#if defined(_win_)
399 i64 currentPosition = GetPosition();
400 if (currentPosition == -1L) {
401 return false;
402 }
403 Seek(length, sSet);
404 if (!::SetEndOfFile(Fd_)) {
405 return false;
406 }
407 if (currentPosition < length) {
408 Seek(currentPosition, sSet);
409 }
410 return true;
411#elif defined(_unix_)
412 return (0 == ftruncate(Fd_, (off_t)length));
413#else
414 #error unsupported platform
415#endif
416}
417
418bool TFileHandle::Reserve(i64 length) noexcept {
419 // FIXME this should reserve disk space with fallocate

Callers 10

LoadMethod · 0.45
Y_UNIT_TESTFunction · 0.45
ResizeMethod · 0.45
TestResizeMethod · 0.45
TestCacheMethod · 0.45
TDirectIOBufferedFileMethod · 0.45
TImplMethod · 0.45
ResizeAndResetMethod · 0.45
DoNextMethod · 0.45
DoUndoMethod · 0.45

Calls 2

ftruncateFunction · 0.70
GetLengthFunction · 0.50

Tested by 2

TestResizeMethod · 0.36
TestCacheMethod · 0.36