aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2023-11-13 13:46:57 +0000
committerfanquake <fanquake@gmail.com>2023-11-13 14:10:54 +0000
commit63423480723de8f4da67e9f4a715cca15498a4ca (patch)
tree9afc80788c7c0618d11b9a2cd68d33b3c52bd41e /src
parent29c2c903621f7daae26113dd2902c016b56929d4 (diff)
parentbbbbdb0cd57d75a06357d2811363d30a498f4499 (diff)
Merge bitcoin/bitcoin#28076: util: Replace std::filesystem with util/fs.h
bbbbdb0cd57d75a06357d2811363d30a498f4499 ci: Add filesystem lint check (MarcoFalke) fada2f91108a56cc5c447bd6b6fac411e4d5cdca refactor: Replace <filesystem> with <util/fs.h> (MarcoFalke) Pull request description: Using `std::filesystem` is problematic: * There is a `fs` namespace wrapper for it. So having two ways to achieve the same is confusing. * Not using the `fs` wrapper is dangerous and buggy, because it disables known bugs by deleting problematic functions. Fix all issues by removing use of it and adding a linter to avoid using it again in the future. ACKs for top commit: TheCharlatan: ACK bbbbdb0cd57d75a06357d2811363d30a498f4499 fanquake: ACK bbbbdb0cd57d75a06357d2811363d30a498f4499 🦀 Tree-SHA512: 0e2d49742b08eb2635e6fce41485277cb9c40fe20b81017c391d3472a43787db1278a236825714ca1e41c9d2f59913865cfb0c649e3c8ab1fb598c849f80c660
Diffstat (limited to 'src')
-rw-r--r--src/bitcoin-chainstate.cpp6
-rw-r--r--src/common/args.cpp1
-rw-r--r--src/policy/fees.cpp4
-rw-r--r--src/util/fs.h1
-rw-r--r--src/util/fs_helpers.cpp4
5 files changed, 7 insertions, 9 deletions
diff --git a/src/bitcoin-chainstate.cpp b/src/bitcoin-chainstate.cpp
index fc83a4ad3a..995b4781fc 100644
--- a/src/bitcoin-chainstate.cpp
+++ b/src/bitcoin-chainstate.cpp
@@ -26,13 +26,13 @@
#include <scheduler.h>
#include <script/sigcache.h>
#include <util/chaintype.h>
+#include <util/fs.h>
#include <util/thread.h>
#include <validation.h>
#include <validationinterface.h>
#include <cassert>
#include <cstdint>
-#include <filesystem>
#include <functional>
#include <iosfwd>
#include <memory>
@@ -50,8 +50,8 @@ int main(int argc, char* argv[])
<< " BREAK IN FUTURE VERSIONS. DO NOT USE ON YOUR ACTUAL DATADIR." << std::endl;
return 1;
}
- std::filesystem::path abs_datadir = std::filesystem::absolute(argv[1]);
- std::filesystem::create_directories(abs_datadir);
+ fs::path abs_datadir{fs::absolute(argv[1])};
+ fs::create_directories(abs_datadir);
// SETUP: Context
diff --git a/src/common/args.cpp b/src/common/args.cpp
index cfaa4de72d..1f25d13bee 100644
--- a/src/common/args.cpp
+++ b/src/common/args.cpp
@@ -28,7 +28,6 @@
#include <cstdint>
#include <cstdlib>
#include <cstring>
-#include <filesystem>
#include <map>
#include <optional>
#include <stdexcept>
diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp
index 9557594622..654c4cf0ce 100644
--- a/src/policy/fees.cpp
+++ b/src/policy/fees.cpp
@@ -1044,8 +1044,8 @@ void CBlockPolicyEstimator::FlushUnconfirmed()
std::chrono::hours CBlockPolicyEstimator::GetFeeEstimatorFileAge()
{
- auto file_time = std::filesystem::last_write_time(m_estimation_filepath);
- auto now = std::filesystem::file_time_type::clock::now();
+ auto file_time{fs::last_write_time(m_estimation_filepath)};
+ auto now{fs::file_time_type::clock::now()};
return std::chrono::duration_cast<std::chrono::hours>(now - file_time);
}
diff --git a/src/util/fs.h b/src/util/fs.h
index 8f79f6cba6..7e2803b6aa 100644
--- a/src/util/fs.h
+++ b/src/util/fs.h
@@ -184,6 +184,7 @@ static inline path PathFromString(const std::string& string)
* already exists or is a symlink to an existing directory.
* This is a temporary workaround for an issue in libstdc++ that has been fixed
* upstream [PR101510].
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510
*/
static inline bool create_directories(const std::filesystem::path& p)
{
diff --git a/src/util/fs_helpers.cpp b/src/util/fs_helpers.cpp
index 2a9eb3502e..8aa7493aa8 100644
--- a/src/util/fs_helpers.cpp
+++ b/src/util/fs_helpers.cpp
@@ -11,13 +11,11 @@
#include <logging.h>
#include <sync.h>
-#include <tinyformat.h>
#include <util/fs.h>
#include <util/getuniquepath.h>
#include <util/syserror.h>
#include <cerrno>
-#include <filesystem>
#include <fstream>
#include <map>
#include <memory>
@@ -263,7 +261,7 @@ bool RenameOver(fs::path src, fs::path dest)
{
#ifdef __MINGW64__
// This is a workaround for a bug in libstdc++ which
- // implements std::filesystem::rename with _wrename function.
+ // implements fs::rename with _wrename function.
// This bug has been fixed in upstream:
// - GCC 10.3: 8dd1c1085587c9f8a21bb5e588dfe1e8cdbba79e
// - GCC 11.1: 1dfd95f0a0ca1d9e6cbc00e6cbfd1fa20a98f312