aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
authorJeff Garzik <[email protected]>2012-05-17 08:46:33 -0700
committerJeff Garzik <[email protected]>2012-05-17 08:46:33 -0700
commitb56843b25356784d6806b2cdd6506bfb2e066445 (patch)
treef2e3f8b379328089349fb105d08b64b7cc8e1b18 /src/util.cpp
parentMerge pull request #1319 from Diapolo/add_new_languages (diff)
parentCAddrDB: Replace BDB-managed addr.dat with internally managed peers.dat (diff)
downloaddiscoin-b56843b25356784d6806b2cdd6506bfb2e066445.tar.xz
discoin-b56843b25356784d6806b2cdd6506bfb2e066445.zip
Merge pull request #1198 from jgarzik/addrman
Replace BDB-managed addr.dat with bitcoin-managed peers.dat
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 823d00a4e..82c16feda 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -910,6 +910,27 @@ void CreatePidFile(const boost::filesystem::path &path, pid_t pid)
}
}
+bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest)
+{
+#ifdef WIN32
+ return MoveFileEx(src.string().c_str(), dest.string().c_str(),
+ MOVEFILE_REPLACE_EXISTING);
+#else
+ int rc = std::rename(src.string().c_str(), dest.string().c_str());
+ return (rc == 0);
+#endif /* WIN32 */
+}
+
+void FileCommit(FILE *fileout)
+{
+ fflush(fileout); // harmless if redundantly called
+#ifdef WIN32
+ _commit(_fileno(fileout));
+#else
+ fsync(fileno(fileout));
+#endif
+}
+
int GetFilesize(FILE* file)
{
int nSavePos = ftell(file);