diff options
author | Vasil Dimov <vd@FreeBSD.org> | 2020-03-14 20:58:55 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2022-02-10 08:16:05 +0000 |
commit | ee822d85d6de7db85416190cf843ad74147519cf (patch) | |
tree | a51d0bf0c2d02e9eec85e38c9ef81c40eb0f87cc /src/util/system.h | |
parent | 243a9c39250dee95b6fe62ac5ae2f8e3eafecf1b (diff) | |
download | bitcoin-ee822d85d6de7db85416190cf843ad74147519cf.tar.xz |
util: use stronger-guarantee rename method
Use std::filesystem::rename() instead of std::rename(). We rely on the
destination to be overwritten if it exists, but std::rename()'s behavior
is implementation-defined in this case.
Diffstat (limited to 'src/util/system.h')
-rw-r--r-- | src/util/system.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/util/system.h b/src/util/system.h index 6b7bd38cc2..a72ba3f3ed 100644 --- a/src/util/system.h +++ b/src/util/system.h @@ -69,7 +69,13 @@ 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); + +/** + * Rename src to dest. + * @return true if the rename was successful. + */ [[nodiscard]] bool RenameOver(fs::path src, fs::path dest); + bool LockDirectory(const fs::path& directory, const std::string lockfile_name, bool probe_only=false); void UnlockDirectory(const fs::path& directory, const std::string& lockfile_name); bool DirIsWritable(const fs::path& directory); |