Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
fs_helpers.h
Go to the documentation of this file.
1// Copyright (c) 2009-2010 Satoshi Nakamoto
2// Copyright (c) 2009-2023 The Bitcoin Core developers
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef BITCOIN_UTIL_FS_HELPERS_H
7#define BITCOIN_UTIL_FS_HELPERS_H
8
9#include <util/fs.h>
10
11#include <cstdint>
12#include <cstdio>
13#include <iosfwd>
14#include <limits>
15
20bool FileCommit(FILE *file);
21
27
28bool TruncateFile(FILE *file, unsigned int length);
30void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length);
31[[nodiscard]] bool RenameOver(fs::path src, fs::path dest);
32bool LockDirectory(const fs::path &directory, const std::string lockfile_name,
33 bool probe_only = false);
35 const std::string &lockfile_name);
38
46std::streampos
47GetFileSize(const char *path,
48 std::streamsize max = std::numeric_limits<std::streamsize>::max());
49
55
58
59#ifdef WIN32
61#endif
62
63#endif // BITCOIN_UTIL_FS_HELPERS_H
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition fs.h:30
fs::path GetDefaultDataDir()
Definition args.cpp:759
void UnlockDirectory(const fs::path &directory, const std::string &lockfile_name)
bool DirIsWritable(const fs::path &directory)
bool RenameOver(fs::path src, fs::path dest)
int RaiseFileDescriptorLimit(int nMinFD)
This function tries to raise the file descriptor limit to the requested number.
std::streampos GetFileSize(const char *path, std::streamsize max=std::numeric_limits< std::streamsize >::max())
Get the size of a file by scanning it.
void DirectoryCommit(const fs::path &dirname)
Sync directory contents.
void ReleaseDirectoryLocks()
Release all directory locks.
bool TryCreateDirectories(const fs::path &p)
Ignores exceptions thrown by create_directories if the requested directory exists.
void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length)
This function tries to make a particular range of a file allocated (corresponding to disk space) it i...
bool LockDirectory(const fs::path &directory, const std::string lockfile_name, bool probe_only=false)
bool TruncateFile(FILE *file, unsigned int length)
bool CheckDiskSpace(const fs::path &dir, uint64_t additional_bytes=0)
bool FileCommit(FILE *file)
Ensure file contents are fully committed to disk, using a platform-specific feature analogous to fsyn...
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85