mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-05 13:11:57 +02:00
util: Introduce DirectoryCommit commit function to sync a directory
This commit is contained in:
committed by
Luke Dashjr
parent
ce5cbaea63
commit
220bb16cbe
@ -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;
|
||||
|
@ -62,6 +62,13 @@ void PrintExceptionContinue(const std::exception *pex, const char* pszThread);
|
||||
* feature analogous to fsync().
|
||||
*/
|
||||
bool FileCommit(FILE *file);
|
||||
|
||||
/**
|
||||
* Sync directory contents. This is required on some environments to ensure that
|
||||
* newly created files are committed to disk.
|
||||
*/
|
||||
void DirectoryCommit(const fs::path &dirname);
|
||||
|
||||
bool TruncateFile(FILE *file, unsigned int length);
|
||||
int RaiseFileDescriptorLimit(int nMinFD);
|
||||
void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length);
|
||||
|
Reference in New Issue
Block a user