Changeset View
Changeset View
Standalone View
Standalone View
src/util/system.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2019 The Bitcoin Core developers | // Copyright (c) 2009-2019 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#if defined(HAVE_CONFIG_H) | |||||
#include <config/bitcoin-config.h> // For HAVE_FDATASYNC | |||||
#endif | |||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <chainparamsbase.h> | #include <chainparamsbase.h> | ||||
#include <sync.h> | #include <sync.h> | ||||
#include <util/strencodings.h> | #include <util/strencodings.h> | ||||
#include <util/string.h> | #include <util/string.h> | ||||
#include <util/translation.h> | #include <util/translation.h> | ||||
▲ Show 20 Lines • Show All 1,122 Lines • ▼ Show 20 Lines | |||||
#ifdef WIN32 | #ifdef WIN32 | ||||
HANDLE hFile = (HANDLE)_get_osfhandle(_fileno(file)); | HANDLE hFile = (HANDLE)_get_osfhandle(_fileno(file)); | ||||
if (FlushFileBuffers(hFile) == 0) { | if (FlushFileBuffers(hFile) == 0) { | ||||
LogPrintf("%s: FlushFileBuffers failed: %d\n", __func__, | LogPrintf("%s: FlushFileBuffers failed: %d\n", __func__, | ||||
GetLastError()); | GetLastError()); | ||||
return false; | return false; | ||||
} | } | ||||
#else | #else | ||||
#if defined(HAVE_FDATASYNC) | #if HAVE_FDATASYNC | ||||
// Ignore EINVAL for filesystems that don't support sync | // Ignore EINVAL for filesystems that don't support sync | ||||
if (fdatasync(fileno(file)) != 0 && errno != EINVAL) { | if (fdatasync(fileno(file)) != 0 && errno != EINVAL) { | ||||
LogPrintf("%s: fdatasync failed: %d\n", __func__, errno); | LogPrintf("%s: fdatasync failed: %d\n", __func__, errno); | ||||
return false; | return false; | ||||
} | } | ||||
#elif defined(MAC_OSX) && defined(F_FULLFSYNC) | #elif defined(MAC_OSX) && defined(F_FULLFSYNC) | ||||
// Manpage says "value other than -1" is returned on success | // Manpage says "value other than -1" is returned on success | ||||
if (fcntl(fileno(file), F_FULLFSYNC, 0) == -1) { | if (fcntl(fileno(file), F_FULLFSYNC, 0) == -1) { | ||||
▲ Show 20 Lines • Show All 249 Lines • Show Last 20 Lines |