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

Method Flush

util/system/file.cpp:473–502  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

471}
472
473bool TFileHandle::Flush() noexcept {
474 if (!IsOpen()) {
475 return false;
476 }
477#if defined(_win_)
478 bool ok = ::FlushFileBuffers(Fd_) != 0;
479 /*
480 * FlushFileBuffers fails if hFile is a handle to the console output.
481 * That is because the console output is not buffered.
482 * The function returns FALSE, and GetLastError returns ERROR_INVALID_HANDLE.
483 */
484 return ok || GetLastError() == ERROR_INVALID_HANDLE;
485#elif defined(_unix_)
486 int ret = ::fsync(Fd_);
487
488 /*
489 * Ignore EROFS, EINVAL - fd is bound to a special file
490 * (PIPE, FIFO, or socket) which does not support synchronization.
491 * Fail in case of EIO, ENOSPC, EDQUOT - data might be lost.
492 */
493 return ret == 0 || errno == EROFS || errno == EINVAL
494 #if defined(_darwin_)
495 // ENOTSUP fd does not refer to a vnode
496 || errno == ENOTSUP
497 #endif
498 ;
499#else
500 #error unsupported platform
501#endif
502}
503
504bool TFileHandle::FlushData() noexcept {
505#if defined(_linux_)

Callers 11

DoFinishMethod · 0.45
BasicTestFunction · 0.45
FlushMethod · 0.45
TestRWMethod · 0.45
TestFlushMethod · 0.45
TestFlushSpecialFileMethod · 0.45
TestRawReadMethod · 0.45
TestReadMethod · 0.45
TestRawPreadMethod · 0.45
TestPreadMethod · 0.45
FinishMethod · 0.45

Calls 1

fsyncFunction · 0.85

Tested by 7

TestRWMethod · 0.36
TestFlushMethod · 0.36
TestFlushSpecialFileMethod · 0.36
TestRawReadMethod · 0.36
TestReadMethod · 0.36
TestRawPreadMethod · 0.36
TestPreadMethod · 0.36