aboutsummaryrefslogtreecommitdiff
path: root/src/util/system.cpp
diff options
context:
space:
mode:
authorEvan Klitzke <evan@eklitzke.org>2018-03-15 06:54:11 -0700
committerLuke Dashjr <luke-jr+git@utopios.org>2020-08-25 16:46:46 +0000
commit220bb16cbee5b91d0bc0fcc6c71560d631295fa5 (patch)
treebc8068b3a2abe2c0a03d1ad5a660e83cc32fb671 /src/util/system.cpp
parentce5cbaea63ad4ea78e533bdb14f47f414061ae7f (diff)
downloadbitcoin-220bb16cbee5b91d0bc0fcc6c71560d631295fa5.tar.xz
util: Introduce DirectoryCommit commit function to sync a directory
Diffstat (limited to 'src/util/system.cpp')
-rw-r--r--src/util/system.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/util/system.cpp b/src/util/system.cpp
index 01c588b0d3..43c6ae54ab 100644
--- a/src/util/system.cpp
+++ b/src/util/system.cpp
@@ -1043,6 +1043,15 @@ bool FileCommit(FILE *file)
return true;
}
+void DirectoryCommit(const fs::path &dirname)
+{
+#ifndef WIN32
+ FILE* file = fsbridge::fopen(dirname, "r");
+ fsync(fileno(file));
+ fclose(file);
+#endif
+}
+
bool TruncateFile(FILE *file, unsigned int length) {
#if defined(WIN32)
return _chsize(_fileno(file), length) == 0;