Replace boost::filesystem with std::filesystem#19245
pull
kiminuo
wants to merge
28
commits into
bitcoin:master
from
kiminuo:feature/2020-06-replace-boost-filesystem-with-cpp17-filesystem
changing
35
files
+118−377
kiminuo
commented at 11:39 am on June 11, 2020:
contributor
Introduction
C++17 has introduced the filesystem library. cppreference.com describes very well the origin of the library:
The filesystem library was originally developed as boost.filesystem, was published as the technical specification ISO/IEC TS 18822:2015, and finally merged to ISO C++ as of C++17. The boost implementation is currently available on more compilers and platforms than the C++17 library.
This draft PR was created to gain feedback and examine what would be necessary to switch from boost::filesystem to std::filesystem in bitcoin codebase.
Bitcoin codebase contains src/fs.h which is a wrapper for the currently used filesystem library. The first impression is that one may just replace namespace fs = boost::filesystem; with namespace fs = std::filesystem; and all will be good. Unfortunately, there are some differences between the Boost’s filesystem library and the c++17 filesystem library. A nice summary by Davis Herring can be read here.
Differences between filesystem implementations that affects Bitcoin code
boost::filesystem::system_complete() was renamed to std::filesystem::absolute() [source]
#19460 (multiprocess: Add bitcoin-wallet -ipcconnect option by ryanofsky)
#18077 (net: Add NAT-PMP port forwarding support by hebasto)
#17127 (util: Correct permissions for datadir and wallets subdir by hebasto)
#10102 ([experimental] Multiprocess bitcoin by ryanofsky)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
DrahtBot added the label
Needs rebase
on Jun 17, 2020
kiminuo force-pushed
on Jun 20, 2020
DrahtBot removed the label
Needs rebase
on Jun 20, 2020
DrahtBot added the label
Needs rebase
on Jun 21, 2020
laanwj referenced this in commit
e3fa3c7d67
on Jun 22, 2020
kiminuo force-pushed
on Jul 5, 2020
DrahtBot removed the label
Needs rebase
on Jul 5, 2020
in
src/fs.cpp:40
in
8566218bd4outdated
31@@ -31,6 +32,14 @@ FILE *fopen(const fs::path& p, const char *mode)
32 #endif
33 }
3435+fs::path unique_path() {
36+ // TODO: Do not use Boost in this implementation
37+ boost::filesystem::path p = boost::filesystem::unique_path();
38+ fs::path p2{p.string()};
39+
40+ return p2;
kiminuo referenced this in commit
333ab6ad42
on Jul 12, 2020
elichai
commented at 9:02 am on July 26, 2020:
contributor
Nice! Please ping me when it’s ready for review :)
kiminuo referenced this in commit
b9592a96fc
on Jul 30, 2020
kiminuo referenced this in commit
182d5a88ef
on Jul 30, 2020
kiminuo referenced this in commit
afb0d6988a
on Jul 30, 2020
kiminuo referenced this in commit
7bc3b41a2a
on Jul 30, 2020
kiminuo force-pushed
on Jul 30, 2020
MarcoFalke added this to the milestone 0.22.0
on Aug 2, 2020
DrahtBot added the label
Needs rebase
on Aug 3, 2020
kiminuo referenced this in commit
141b1c0646
on Aug 7, 2020
kiminuo force-pushed
on Aug 7, 2020
DrahtBot removed the label
Needs rebase
on Aug 7, 2020
DrahtBot added the label
Needs rebase
on Aug 31, 2020
kiminuo force-pushed
on Sep 2, 2020
kiminuo referenced this in commit
84adbdf04d
on Sep 2, 2020
DrahtBot removed the label
Needs rebase
on Sep 2, 2020
DrahtBot added the label
Needs rebase
on Sep 7, 2020
elichai
commented at 10:35 am on November 19, 2020:
contributor
@kiminuo Now that #20413 is merged, are you planning on rebasing this and getting it ready for review?
kiminuo
commented at 10:52 am on November 19, 2020:
contributor
@kiminuo Now that #20413 is merged, are you planning on rebasing this and getting it ready for review?
I will get to it (hopefully soon ™). However, @MarcoFalke mentioned on IRC briefly that std::fs is not available on some supported OSs even with C++17 enabled. I’m not sure I understood correctly. If true, it would delay this feature months or years.
If you want to work on this. No problem. I’m quite busy.
kiminuo referenced this in commit
fd46064ff6
on Nov 19, 2020
kiminuo referenced this in commit
2b5b4a65bc
on Nov 20, 2020
kiminuo force-pushed
on Nov 20, 2020
DrahtBot removed the label
Needs rebase
on Nov 20, 2020
kiminuo referenced this in commit
6c01a2c8e0
on Nov 24, 2020
kiminuo force-pushed
on Nov 24, 2020
DrahtBot added the label
Needs rebase
on Nov 24, 2020
kiminuo force-pushed
on Nov 26, 2020
kiminuo referenced this in commit
9d6d916f0f
on Nov 26, 2020
kiminuo force-pushed
on Nov 26, 2020
DrahtBot removed the label
Needs rebase
on Nov 26, 2020
DrahtBot added the label
Needs rebase
on Nov 30, 2020
kiminuo referenced this in commit
4ba6d440eb
on Nov 30, 2020
kiminuo force-pushed
on Nov 30, 2020
DrahtBot removed the label
Needs rebase
on Nov 30, 2020
kiminuo referenced this in commit
7ce843cb4b
on Dec 1, 2020
kiminuo force-pushed
on Dec 1, 2020
kiminuo referenced this in commit
58a9971b35
on Dec 3, 2020
kiminuo force-pushed
on Dec 3, 2020
kiminuo referenced this in commit
087ccc5863
on Dec 3, 2020
kiminuo force-pushed
on Dec 3, 2020
DrahtBot added the label
Needs rebase
on Dec 12, 2020
MarcoFalke added the label
Waiting for other
on Dec 15, 2020
MarcoFalke removed this from the milestone 22.0
on Dec 15, 2020
kiminuo referenced this in commit
fda8dc9939
on Dec 15, 2020
kiminuo force-pushed
on Dec 15, 2020
DrahtBot removed the label
Needs rebase
on Dec 15, 2020
Modify fs.h to switch from boost::filesystem to std::filesystem
(cherry picked from commit b526d92bf6b3deecb8bb2a9f6fcc50476a28ea80)
(cherry picked from commit 29cd1a22327469dcd625d24c9a317be23144887f)
00dfc62408
Replace `fs::system_complete(path)` with `fs::absolute(path)`
Resources:
* https://stackoverflow.com/a/46271698
* https://www.bfilipek.com/2019/05/boost-to-stdfs.html#differences-found-systemcomplete
(cherry picked from commit 88bb4e1bdfc43a449ea9d62d9336de9e162babfd)
(cherry picked from commit fc0d5a4c1c7153167afbca028d543ea65701658c)
6ee22b607f
Replace boost::filesystem::absolute(path p, path base) with `std::filesystem::absolute(base_dir / p)`
Remove `fs::path::imbue()` call as it no longer exist in `std::filesystem`
(cherry picked from commit eb89f20e1a45f1c58ec7396b376b65c7ae50bf28)
(cherry picked from commit b24d14961cd93a3229e4983ee31f56277b612ed5)
e929c64bd4
Replace `fs::unique_path()` with `fsbridge::unique_path()` for now to re-implement it later
Resources:
* https://stackoverflow.com/questions/43316527/what-is-the-c17-equivalent-to-boostfilesystemunique-path
(cherry picked from commit fdeb20204a23b71a268c88b9d52d8678ea5b140d)
(cherry picked from commit 1a09157f3ca66f2931a55cf94a25cfa9944079a4)
92f4300362
Remove `BOOST_FILESYSTEM_C_STR` as we want to use the overload with `fs::path`
See (1) to understand what the macro `BOOST_FILESYSTEM_C_STR` does.
Resources:
(1) https://www.boost.org/doc/libs/1_70_0/boost/filesystem/fstream.hpp
(2) https://stackoverflow.com/questions/821873/how-to-open-an-stdfstream-ofstream-or-ifstream-with-a-unicode-filename/#54842261
(cherry picked from commit 7543252fe53f992f93d6af802a8f5f30d40cce15)
(cherry picked from commit a02bba11c22108ecc4a88dbc106c2b7693b4838a)
38d8432c1b
Remove workaround for opening UTF-8 paths on Windows
(cherry picked from commit 6df4d92034b4302870162e108f48cefd4e21bd1a)
(cherry picked from commit f71054b2a407a089e1915b992a536c8731356922)
4aa0452ceb
Remove `boost/filesystem/fstream.hpp` from `EXPECTED_BOOST_INCLUDES` in `lint-includes.sh`
(cherry picked from commit 3358071a54c9d803f91b4daca00cf963b4390863)
(cherry picked from commit 8d1464d4513bf705a7ae904c96a768c9b08ce027)
536ca52047
Replace `boost::system::error_code` with `std::error_code`
(cherry picked from commit 6d375ab584355a78ff2f2e347063b990b1573ee5)
(cherry picked from commit 593e7df400e0d71e1e355668ee747491fb60749b)
# Conflicts:
# src/wallet/walletutil.cpp
8038c17224
Fix db test "getwalletenv_file"
(cherry picked from commit 2e19c4cbc29e9778c8d037961f156a5f1b7280d9)
(cherry picked from commit 1043687a555101c0b3550dde48bfd29c8e82c28f)
926a704f3d
Fix init_tests
(cherry picked from commit db44346266d71b716f136fe6d8febf819168ce27)
(cherry picked from commit 62e7fb353efbbc125b1a96ef78e0331149b144ca)
ab400705d0
User u8path rather -- TODO: Verify!!
(cherry picked from commit 018574609b16ae45f2448f9437267ac68c1e70d7)
(cherry picked from commit 2d8823f1bdb530088e44c2cdca040ad146ce0752)
Modify fs::absolute call in ArgsManager::GetSettingsPath.2f52c5679b
To split into multiple commits0349794528
Fix tests.834afbb3fc
Fix util_tests.5ee8d971b0
why?4187d5ae12
Test.9dd1c910d3
Test.7b071c5491
workaround: dbwrapper_tests13f1cb6db0
Test with 20.04b96e01722d
kiminuo force-pushed
on Dec 16, 2020
Test: Use Clang 10.cf948ffac6
sipa added the label
Up for grabs
on Dec 16, 2020
MarcoFalke
commented at 6:34 am on December 17, 2020:
member
Hi, catching up on the IRC log.
I just wanted to say that this is blocked on #20460 and there is nothing you can do about this in this pull. Fixing #20460 will need build system and gitian/guix, as well as CI changes. This would be too much to do here.
MarcoFalke removed the label
Up for grabs
on Dec 17, 2020
fanquake renamed this:
[WIP DONOTMERGE] Replace boost::filesystem with std::filesystem (in c++17)
Replace boost::filesystem with std::filesystem
on Dec 17, 2020
fanquake marked this as a draft
on Dec 17, 2020
fanquake
commented at 2:30 pm on December 22, 2020:
member
Thanks for your work here so far @kiminuo. I’ve addressed the build system requirements, and combined this changes into #20744 (still attributed to you). However due to runtime and compiler requirements it’s unlikely we’ll be able to start using them just yet. I’m going to close this PR in favour of #20744 for now.
fanquake closed this
on Dec 22, 2020
MarcoFalke referenced this in commit
3ace3a17c9
on Feb 3, 2022
DrahtBot locked this
on Feb 15, 2022
fanquake removed the label
Waiting for other
on Jan 12, 2023
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2024-12-18 12:12 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me