util: Introduce DirectoryCommit commit function to sync a directory

This commit is contained in:
Evan Klitzke
2018-03-15 06:54:11 -07:00
committed by Luke Dashjr
parent ce5cbaea63
commit 220bb16cbe
2 changed files with 16 additions and 0 deletions

View File

@@ -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;