Skip to content

Commit fada2f9

Browse files
author
MarcoFalke
committed
refactor: Replace <filesystem> with <util/fs.h>
All code in this repo uses <util/fs.h>, except for a few lines. This is confusing and potentially dangerous, if the safe <util/fs.h> wrappers are not used.
1 parent f5c5dda commit fada2f9

File tree

5 files changed

+7
-9
lines changed

5 files changed

+7
-9
lines changed

src/bitcoin-chainstate.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
#include <scheduler.h>
2727
#include <script/sigcache.h>
2828
#include <util/chaintype.h>
29+
#include <util/fs.h>
2930
#include <util/thread.h>
3031
#include <validation.h>
3132
#include <validationinterface.h>
3233

3334
#include <cassert>
3435
#include <cstdint>
35-
#include <filesystem>
3636
#include <functional>
3737
#include <iosfwd>
3838
#include <memory>
@@ -50,8 +50,8 @@ int main(int argc, char* argv[])
5050
<< " BREAK IN FUTURE VERSIONS. DO NOT USE ON YOUR ACTUAL DATADIR." << std::endl;
5151
return 1;
5252
}
53-
std::filesystem::path abs_datadir = std::filesystem::absolute(argv[1]);
54-
std::filesystem::create_directories(abs_datadir);
53+
fs::path abs_datadir{fs::absolute(argv[1])};
54+
fs::create_directories(abs_datadir);
5555

5656

5757
// SETUP: Context

src/common/args.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include <cstdint>
2929
#include <cstdlib>
3030
#include <cstring>
31-
#include <filesystem>
3231
#include <map>
3332
#include <optional>
3433
#include <stdexcept>

src/policy/fees.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,8 +1031,8 @@ void CBlockPolicyEstimator::FlushUnconfirmed()
10311031

10321032
std::chrono::hours CBlockPolicyEstimator::GetFeeEstimatorFileAge()
10331033
{
1034-
auto file_time = std::filesystem::last_write_time(m_estimation_filepath);
1035-
auto now = std::filesystem::file_time_type::clock::now();
1034+
auto file_time{fs::last_write_time(m_estimation_filepath)};
1035+
auto now{fs::file_time_type::clock::now()};
10361036
return std::chrono::duration_cast<std::chrono::hours>(now - file_time);
10371037
}
10381038

src/util/fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ static inline path PathFromString(const std::string& string)
184184
* already exists or is a symlink to an existing directory.
185185
* This is a temporary workaround for an issue in libstdc++ that has been fixed
186186
* upstream [PR101510].
187+
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101510
187188
*/
188189
static inline bool create_directories(const std::filesystem::path& p)
189190
{

src/util/fs_helpers.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@
1111

1212
#include <logging.h>
1313
#include <sync.h>
14-
#include <tinyformat.h>
1514
#include <util/fs.h>
1615
#include <util/getuniquepath.h>
1716
#include <util/syserror.h>
1817

1918
#include <cerrno>
20-
#include <filesystem>
2119
#include <fstream>
2220
#include <map>
2321
#include <memory>
@@ -263,7 +261,7 @@ bool RenameOver(fs::path src, fs::path dest)
263261
{
264262
#ifdef __MINGW64__
265263
// This is a workaround for a bug in libstdc++ which
266-
// implements std::filesystem::rename with _wrename function.
264+
// implements fs::rename with _wrename function.
267265
// This bug has been fixed in upstream:
268266
// - GCC 10.3: 8dd1c1085587c9f8a21bb5e588dfe1e8cdbba79e
269267
// - GCC 11.1: 1dfd95f0a0ca1d9e6cbc00e6cbfd1fa20a98f312

0 commit comments

Comments
 (0)