MCPcopy Create free account
hub / github.com/boostorg/filesystem / data_sync

Function data_sync

src/operations.cpp:649–673  ·  view source on GitHub ↗

Flushes buffered data written to the file to permanent storage

Source from the content-addressed store, hash-verified

647
648//! Flushes buffered data written to the file to permanent storage
649inline int data_sync(int fd)
650{
651#if defined(BOOST_FILESYSTEM_HAS_FDATASYNC) && !(defined(__APPLE__) && defined(__MACH__) && defined(F_FULLFSYNC))
652 while (true)
653 {
654 int err = ::fdatasync(fd);
655 if (BOOST_UNLIKELY(err != 0))
656 {
657 err = errno;
658 // POSIX says fsync can return EINTR (https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html).
659 // It doesn't say so for fdatasync, but it is reasonable to expect it as well.
660 if (err == EINTR)
661 continue;
662
663 return err;
664 }
665
666 break;
667 }
668
669 return 0;
670#else
671 return full_sync(fd);
672#endif
673}
674
675//! Hints the filesystem to opportunistically preallocate storage for a file
676inline int preallocate_storage(int file, uintmax_t size)

Callers 1

copy_fileFunction · 0.85

Calls 1

full_syncFunction · 0.85

Tested by

no test coverage detected