MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / FileCommit

Function FileCommit

src/util/fs_helpers.cpp:108–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108bool FileCommit(FILE* file)
109{
110 if (fflush(file) != 0) { // harmless if redundantly called
111 LogError("fflush failed: %s", SysErrorString(errno));
112 return false;
113 }
114#ifdef WIN32
115 HANDLE hFile = (HANDLE)_get_osfhandle(_fileno(file));
116 if (FlushFileBuffers(hFile) == 0) {
117 LogError("FlushFileBuffers failed: %s", Win32ErrorString(GetLastError()));
118 return false;
119 }
120#elif defined(__APPLE__) && defined(F_FULLFSYNC)
121 if (fcntl(fileno(file), F_FULLFSYNC, 0) == -1) { // Manpage says "value other than -1" is returned on success
122 LogError("fcntl F_FULLFSYNC failed: %s", SysErrorString(errno));
123 return false;
124 }
125#elif HAVE_FDATASYNC
126 if (fdatasync(fileno(file)) != 0 && errno != EINVAL) { // Ignore EINVAL for filesystems that don't support sync
127 LogError("fdatasync failed: %s", SysErrorString(errno));
128 return false;
129 }
130#else
131 if (fsync(fileno(file)) != 0 && errno != EINVAL) {
132 LogError("fsync failed: %s", SysErrorString(errno));
133 return false;
134 }
135#endif
136 return true;
137}
138
139void DirectoryCommit(const fs::path& dirname)
140{

Callers 2

CommitMethod · 0.85
FlushMethod · 0.85

Calls 2

SysErrorStringFunction · 0.85
Win32ErrorStringFunction · 0.85

Tested by

no test coverage detected