|
14 | 14 | #include <tinyformat.h> |
15 | 15 | #include <util/fs.h> |
16 | 16 | #include <util/getuniquepath.h> |
| 17 | +#include <util/syserror.h> |
17 | 18 |
|
18 | 19 | #include <cerrno> |
19 | 20 | #include <filesystem> |
@@ -120,28 +121,28 @@ std::streampos GetFileSize(const char* path, std::streamsize max) |
120 | 121 | bool FileCommit(FILE* file) |
121 | 122 | { |
122 | 123 | if (fflush(file) != 0) { // harmless if redundantly called |
123 | | - LogPrintf("%s: fflush failed: %d\n", __func__, errno); |
| 124 | + LogPrintf("fflush failed: %s\n", SysErrorString(errno)); |
124 | 125 | return false; |
125 | 126 | } |
126 | 127 | #ifdef WIN32 |
127 | 128 | HANDLE hFile = (HANDLE)_get_osfhandle(_fileno(file)); |
128 | 129 | if (FlushFileBuffers(hFile) == 0) { |
129 | | - LogPrintf("%s: FlushFileBuffers failed: %d\n", __func__, GetLastError()); |
| 130 | + LogPrintf("FlushFileBuffers failed: %s\n", Win32ErrorString(GetLastError())); |
130 | 131 | return false; |
131 | 132 | } |
132 | 133 | #elif defined(MAC_OSX) && defined(F_FULLFSYNC) |
133 | 134 | if (fcntl(fileno(file), F_FULLFSYNC, 0) == -1) { // Manpage says "value other than -1" is returned on success |
134 | | - LogPrintf("%s: fcntl F_FULLFSYNC failed: %d\n", __func__, errno); |
| 135 | + LogPrintf("fcntl F_FULLFSYNC failed: %s\n", SysErrorString(errno)); |
135 | 136 | return false; |
136 | 137 | } |
137 | 138 | #elif HAVE_FDATASYNC |
138 | 139 | if (fdatasync(fileno(file)) != 0 && errno != EINVAL) { // Ignore EINVAL for filesystems that don't support sync |
139 | | - LogPrintf("%s: fdatasync failed: %d\n", __func__, errno); |
| 140 | + LogPrintf("fdatasync failed: %s\n", SysErrorString(errno)); |
140 | 141 | return false; |
141 | 142 | } |
142 | 143 | #else |
143 | 144 | if (fsync(fileno(file)) != 0 && errno != EINVAL) { |
144 | | - LogPrintf("%s: fsync failed: %d\n", __func__, errno); |
| 145 | + LogPrintf("fsync failed: %s\n", SysErrorString(errno)); |
145 | 146 | return false; |
146 | 147 | } |
147 | 148 | #endif |
|
0 commit comments