Skip to content

Commit 369d4c0

Browse files
committed
Merge bitcoin/bitcoin#27254: refactor: Extract util/fs from util/system
00e9b97 refactor: Move fs.* to util/fs.* (TheCharlatan) 106b46d Add missing fs.h includes (TheCharlatan) b202b3d Add missing cstddef include in assumptions.h (TheCharlatan) 18fb363 refactor: Extract util/fs_helpers from util/system (Ben Woosley) Pull request description: This pull request is part of the `libbitcoinkernel` project bitcoin/bitcoin#24303 https://github.com/bitcoin/bitcoin/projects/18 and more specifically its "Step 2: Decouple most non-consensus code from libbitcoinkernel". This commit was originally authored by empact and is taken from its parent PR #25152. #### Context There is an ongoing effort to decouple the `ArgsManager` used for command line parsing user-provided arguments from the libbitcoinkernel library (bitcoin/bitcoin#25290, bitcoin/bitcoin#25487, bitcoin/bitcoin#25527, bitcoin/bitcoin#25862, bitcoin/bitcoin#26177, and bitcoin/bitcoin#27125). The `ArgsManager` is defined in `system.h`. A similar pull request extracting functionality from `system.h` has been merged in bitcoin/bitcoin#27238. #### Changes Next to providing better code organization, this PR removes some reliance of the tree of libbitcoinkernel header includes on `system.h` (and thus the `ArgsManager` definition) by moving filesystem related functions out of the `system.*` files. There is already a pair of `fs.h` / `fs.cpp` in the top-level `src/` directory. They were not combined with the files introduced here, to keep the patch cleaner and more importantly because they are often included without the utility functions. The new files are therefore named `fs_helpers` and the existing `fs` files are moved into the util directory. Further commits splitting more functionality out of `system.h` are still in #25152 and will be submitted in separate PRs once this PR has been processed. ACKs for top commit: hebasto: ACK 00e9b97 Tree-SHA512: 31422f148d14ba3c843b99b1550a6fd77c77f350905ca324f93d4f97b652246bc58fa9696c64d1201979cf88733e40be02d262739bb7d417cf22bf506fdb7666
2 parents 5150e28 + 00e9b97 commit 369d4c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+480
-412
lines changed

src/Makefile.am

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ BITCOIN_CORE_H = \
154154
deploymentstatus.h \
155155
external_signer.h \
156156
flatfile.h \
157-
fs.h \
158157
headerssync.h \
159158
httprpc.h \
160159
httpserver.h \
@@ -285,6 +284,8 @@ BITCOIN_CORE_H = \
285284
util/exception.h \
286285
util/fastrange.h \
287286
util/fees.h \
287+
util/fs.h \
288+
util/fs_helpers.h \
288289
util/getuniquepath.h \
289290
util/golombrice.h \
290291
util/hash_type.h \
@@ -694,7 +695,6 @@ libbitcoin_util_a_SOURCES = \
694695
support/lockedpool.cpp \
695696
chainparamsbase.cpp \
696697
clientversion.cpp \
697-
fs.cpp \
698698
logging.cpp \
699699
random.cpp \
700700
randomenv.cpp \
@@ -707,6 +707,8 @@ libbitcoin_util_a_SOURCES = \
707707
util/error.cpp \
708708
util/exception.cpp \
709709
util/fees.cpp \
710+
util/fs.cpp \
711+
util/fs_helpers.cpp \
710712
util/getuniquepath.cpp \
711713
util/hasher.cpp \
712714
util/sock.cpp \
@@ -908,7 +910,6 @@ libbitcoinkernel_la_SOURCES = \
908910
deploymentinfo.cpp \
909911
deploymentstatus.cpp \
910912
flatfile.cpp \
911-
fs.cpp \
912913
hash.cpp \
913914
kernel/chain.cpp \
914915
kernel/checks.cpp \
@@ -951,6 +952,8 @@ libbitcoinkernel_la_SOURCES = \
951952
uint256.cpp \
952953
util/check.cpp \
953954
util/exception.cpp \
955+
util/fs.cpp \
956+
util/fs_helpers.cpp \
954957
util/getuniquepath.cpp \
955958
util/hasher.cpp \
956959
util/moneystr.cpp \

src/addrdb.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <chainparams.h>
1010
#include <clientversion.h>
1111
#include <cstdint>
12-
#include <fs.h>
1312
#include <hash.h>
1413
#include <logging.h>
1514
#include <logging/timer.h>
@@ -19,6 +18,8 @@
1918
#include <streams.h>
2019
#include <tinyformat.h>
2120
#include <univalue.h>
21+
#include <util/fs.h>
22+
#include <util/fs_helpers.h>
2223
#include <util/settings.h>
2324
#include <util/system.h>
2425
#include <util/translation.h>

src/addrdb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#ifndef BITCOIN_ADDRDB_H
77
#define BITCOIN_ADDRDB_H
88

9-
#include <fs.h>
109
#include <net_types.h> // For banmap_t
1110
#include <univalue.h>
11+
#include <util/fs.h>
1212

1313
#include <optional>
1414
#include <vector>

src/banman.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
#include <addrdb.h>
99
#include <common/bloom.h>
10-
#include <fs.h>
1110
#include <net_types.h> // For banmap_t
1211
#include <sync.h>
12+
#include <util/fs.h>
1313

1414
#include <chrono>
1515
#include <cstdint>

src/bench/bench.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
#include <bench/bench.h>
66

7-
#include <fs.h>
87
#include <test/util/setup_common.h>
8+
#include <util/fs.h>
99
#include <util/string.h>
1010

1111
#include <chrono>

src/bench/bench.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#ifndef BITCOIN_BENCH_BENCH_H
66
#define BITCOIN_BENCH_BENCH_H
77

8-
#include <fs.h>
8+
#include <util/fs.h>
99
#include <util/macros.h>
1010

1111
#include <chrono>

src/bench/bench_bitcoin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include <clientversion.h>
88
#include <crypto/sha256.h>
9-
#include <fs.h>
9+
#include <util/fs.h>
1010
#include <util/strencodings.h>
1111
#include <util/system.h>
1212

src/bitcoin-tx.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <consensus/amount.h>
1313
#include <consensus/consensus.h>
1414
#include <core_io.h>
15-
#include <fs.h>
1615
#include <key_io.h>
1716
#include <policy/policy.h>
1817
#include <primitives/transaction.h>
@@ -21,6 +20,7 @@
2120
#include <script/signingprovider.h>
2221
#include <univalue.h>
2322
#include <util/exception.h>
23+
#include <util/fs.h>
2424
#include <util/moneystr.h>
2525
#include <util/rbf.h>
2626
#include <util/strencodings.h>

src/common/init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
#include <common/init.h>
65
#include <chainparams.h>
7-
#include <fs.h>
6+
#include <common/init.h>
87
#include <tinyformat.h>
8+
#include <util/fs.h>
99
#include <util/system.h>
1010
#include <util/translation.h>
1111

src/compat/assumptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#ifndef BITCOIN_COMPAT_ASSUMPTIONS_H
99
#define BITCOIN_COMPAT_ASSUMPTIONS_H
1010

11+
#include <cstddef>
1112
#include <limits>
1213

1314
// Assumption: We assume that the macro NDEBUG is not defined.

0 commit comments

Comments
 (0)