aboutsummaryrefslogtreecommitdiff
path: root/src/fs.h
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2022-01-10 23:48:23 +0200
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2022-01-10 23:48:23 +0200
commit213172c7348091794b173c2edf5f7f3bbe010912 (patch)
treed01bfa550958abbb22d7dfe7baa62d5c66dbbf56 /src/fs.h
parent3d0850cec103950731bfc0f935ad997a4149d4b3 (diff)
downloadbitcoin-213172c7348091794b173c2edf5f7f3bbe010912.tar.xz
refactor: Block unsafe std::string fs::path conversion copy_file calls
There is no change in behavior. This just helps prepare for the transition from boost::filesystem to std::filesystem by avoiding copy_file calls that will be unsafe after the transition to std::filesystem to due lack of a boost::filesystem::path::imbue equivalent and inability to set a predictable locale.
Diffstat (limited to 'src/fs.h')
-rw-r--r--src/fs.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/fs.h b/src/fs.h
index c179be7607..9f18794539 100644
--- a/src/fs.h
+++ b/src/fs.h
@@ -92,6 +92,13 @@ static inline path operator+(path p1, path p2)
return p1;
}
+// Disallow implicit std::string conversion for copy_file
+// to avoid locale-dependent encoding on Windows.
+static inline void copy_file(const path& from, const path& to, copy_option options)
+{
+ boost::filesystem::copy_file(from, to, options);
+}
+
/**
* Convert path object to byte string. On POSIX, paths natively are byte
* strings, so this is trivial. On Windows, paths natively are Unicode, so an