fs::path

Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path::string() method, which have unsafe and unpredictable behavior on Windows (see implementation note in PathToString for details)

Synopsis

Declared in <util/fs.h>

class path
    : public std::filesystem::path

Base Classes

NameDescription
std::filesystem::path

Types

Name
iterator

Type Aliases

Name
__string_view
const_iterator
string_type
value_type

Enums

Name
format

Member Functions

NameDescription
path [constructor]Constructors
operator= Assignment operators
__reserve
append append overloads
assign
begin
c_str
clear
compare
concat
empty
end
extension
filename
generic_string
generic_u16string
generic_u32string
generic_u8string
generic_wstring
has_extension
has_filename
has_parent_path
has_relative_path
has_root_directory
has_root_name
has_root_path
has_stem
is_absolute
is_relative
lexically_normal
lexically_proximate
lexically_relative
make_preferred
native
operator+= Addition assignment operators
operator/= Division assignment operators
parent_path
relative_path
remove_filename
replace_extension
replace_filename
root_directory
root_name
root_path
std_path std_path overloads
stem
string Deleted to forbid std::string conversion, which encodes locale-dependently on Windows.
swap
u16string
u32string
u8string
utf8string Return a UTF-8 representation of the path as a std::string, for compatibility with code using std::string. For code using the newer std::u8string type, it is more efficient to call the inherited std::filesystem::path::u8string method instead.
wstring
operator string_type [deleted]Deleted to forbid implicit string_type conversion, whose type varies by platform and breaks portability.

Static Data Members

Name
preferred_separator

Using Declarations

NameDescription
path Inherit the std::filesystem::path constructors.

Non-Member Functions

NameDescription
operator+Deleted catch-all overload that forbids unsafe path concatenation via operator+.
operator/Deleted catch-all overload that forbids unsafe path append operations via operator/.
::AbsPathForConfigValMost paths passed as configuration arguments are treated as relative to the datadir if they are not absolute.
::BlockPolicyFeeEstPathPath of the block policy fee estimator data file.
::CheckDiskSpaceCheck that a directory has enough free space for an additional write.
::DecodeAsmapRead and check asmap from provided binary file.
::DirectoryCommitSync directory contents. This is required on some environments to ensure that newly created files are committed to disk.
::DumpAnchorsDump the anchor IP address database (anchors.dat)
::GetDefaultDataDirGet the default data directory for the current platform and user.
::IsDirWritableCheck if a directory is writable by creating a temporary file on it.
::MempoolPolicyEstimatorPathPath of the mempool policy estimator data file.
::ReadAnchorsRead the anchor IP address database (anchors.dat)
::ReadBinaryFileRead full contents of a file and return them in a std::string.
::RenameOverRename src to dest.
::TryCreateDirectoriesCreate a directory and any missing parent directories.
::UnlockDirectoryRelease a directory lock previously taken with LockDirectory.
::WriteBinaryFileWrite contents of std::string to a file.
::common::ReadSettingsRead settings file.
::common::WriteSettingsWrite settings file.
::fsbridge::AbsPathJoinHelper function for joining two paths
::fsbridge::fopenOpen a file, handling path encoding correctly across platforms.
::node::FindAssumeutxoChainstateDirReturn a path to the snapshot-based chainstate dir, if one exists.
::node::MempoolPathReturn the on-disk path used to load and save the persisted mempool.
::node::ReadSnapshotBaseBlockhashRead the blockhash of the snapshot base block that was used to construct the chainstate.
::util::GetExePathReturn path to current executable assuming it was invoked with argv0. If path could not be determined, returns an empty path.
::util::LockDirectoryAcquire an exclusive lock on a directory via a lock file.
::wallet::BDBDataFileReturns the path to the Berkeley DB data file for a wallet path.
::wallet::GetWalletDirGet the path of the wallet directory.
::wallet::GetWalletPathDetermine the path that the wallet is stored in
::wallet::IsBDBFileReturns whether the file at the path is a Berkeley DB file.
::wallet::IsSQLiteFileReturns whether the file at the path is a SQLite file.
::wallet::ListDatabasesRecursively list database paths in directory.
::wallet::MakeBerkeleyRODatabaseReturn object giving access to Berkeley Read Only database at specified path.
::wallet::MakeDatabaseCreates or opens a wallet database at the given path.
::wallet::MakeSQLiteDatabaseOpen or create a SQLite wallet database at the given path.
::wallet::SQLiteDataFileReturns the path to the SQLite data file for a wallet path.