Skip to content

Commit fa3da62

Browse files
author
MarcoFalke
committed
Remove DirIsWritable, GetUniquePath
1 parent fad3a97 commit fa3da62

File tree

7 files changed

+4
-88
lines changed

7 files changed

+4
-88
lines changed

src/Makefile.am

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ BITCOIN_CORE_H = \
303303
util/fees.h \
304304
util/fs.h \
305305
util/fs_helpers.h \
306-
util/getuniquepath.h \
307306
util/golombrice.h \
308307
util/hash_type.h \
309308
util/hasher.h \
@@ -739,7 +738,6 @@ libbitcoin_util_a_SOURCES = \
739738
util/fees.cpp \
740739
util/fs.cpp \
741740
util/fs_helpers.cpp \
742-
util/getuniquepath.cpp \
743741
util/hasher.cpp \
744742
util/sock.cpp \
745743
util/syserror.cpp \
@@ -982,7 +980,6 @@ libbitcoinkernel_la_SOURCES = \
982980
util/exception.cpp \
983981
util/fs.cpp \
984982
util/fs_helpers.cpp \
985-
util/getuniquepath.cpp \
986983
util/hasher.cpp \
987984
util/moneystr.cpp \
988985
util/rbf.cpp \

src/test/fs_tests.cpp

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <test/util/setup_common.h>
66
#include <util/fs.h>
77
#include <util/fs_helpers.h>
8-
#include <util/getuniquepath.h>
98

109
#include <boost/test/unit_test.hpp>
1110

@@ -101,29 +100,14 @@ BOOST_AUTO_TEST_CASE(fsbridge_fstream)
101100
BOOST_CHECK_EQUAL(tmpfile1, fsbridge::AbsPathJoin(tmpfile1, ""));
102101
BOOST_CHECK_EQUAL(tmpfile1, fsbridge::AbsPathJoin(tmpfile1, {}));
103102
}
104-
{
105-
fs::path p1 = GetUniquePath(tmpfolder);
106-
fs::path p2 = GetUniquePath(tmpfolder);
107-
fs::path p3 = GetUniquePath(tmpfolder);
108-
109-
// Ensure that the parent path is always the same.
110-
BOOST_CHECK_EQUAL(tmpfolder, p1.parent_path());
111-
BOOST_CHECK_EQUAL(tmpfolder, p2.parent_path());
112-
BOOST_CHECK_EQUAL(tmpfolder, p3.parent_path());
113-
114-
// Ensure that generated paths are actually different.
115-
BOOST_CHECK(p1 != p2);
116-
BOOST_CHECK(p2 != p3);
117-
BOOST_CHECK(p1 != p3);
118-
}
119103
}
120104

121105
BOOST_AUTO_TEST_CASE(rename)
122106
{
123107
const fs::path tmpfolder{m_args.GetDataDirBase()};
124108

125-
const fs::path path1{GetUniquePath(tmpfolder)};
126-
const fs::path path2{GetUniquePath(tmpfolder)};
109+
const fs::path path1{tmpfolder / "a"};
110+
const fs::path path2{tmpfolder / "b"};
127111

128112
const std::string path1_contents{"1111"};
129113
const std::string path2_contents{"2222"};
@@ -158,13 +142,13 @@ BOOST_AUTO_TEST_CASE(create_directories)
158142
// Test fs::create_directories workaround.
159143
const fs::path tmpfolder{m_args.GetDataDirBase()};
160144

161-
const fs::path dir{GetUniquePath(tmpfolder)};
145+
const fs::path dir{tmpfolder / "a"};
162146
fs::create_directory(dir);
163147
BOOST_CHECK(fs::exists(dir));
164148
BOOST_CHECK(fs::is_directory(dir));
165149
BOOST_CHECK(!fs::create_directories(dir));
166150

167-
const fs::path symlink{GetUniquePath(tmpfolder)};
151+
const fs::path symlink{tmpfolder / "b"};
168152
fs::create_directory_symlink(dir, symlink);
169153
BOOST_CHECK(fs::exists(symlink));
170154
BOOST_CHECK(fs::is_symlink(symlink));

src/test/util_tests.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <util/bitdeque.h>
1313
#include <util/fs.h>
1414
#include <util/fs_helpers.h>
15-
#include <util/getuniquepath.h>
1615
#include <util/message.h> // For MessageSign(), MessageVerify(), MESSAGE_MAGIC
1716
#include <util/moneystr.h>
1817
#include <util/overflow.h>
@@ -1245,22 +1244,6 @@ BOOST_AUTO_TEST_CASE(test_LockDirectory)
12451244
fs::remove_all(dirname);
12461245
}
12471246

1248-
BOOST_AUTO_TEST_CASE(test_DirIsWritable)
1249-
{
1250-
// Should be able to write to the data dir.
1251-
fs::path tmpdirname = m_args.GetDataDirBase();
1252-
BOOST_CHECK_EQUAL(DirIsWritable(tmpdirname), true);
1253-
1254-
// Should not be able to write to a non-existent dir.
1255-
tmpdirname = GetUniquePath(tmpdirname);
1256-
BOOST_CHECK_EQUAL(DirIsWritable(tmpdirname), false);
1257-
1258-
fs::create_directory(tmpdirname);
1259-
// Should be able to write to it now.
1260-
BOOST_CHECK_EQUAL(DirIsWritable(tmpdirname), true);
1261-
fs::remove(tmpdirname);
1262-
}
1263-
12641247
BOOST_AUTO_TEST_CASE(test_ToLower)
12651248
{
12661249
BOOST_CHECK_EQUAL(ToLower('@'), '@');

src/util/fs_helpers.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <sync.h>
1414
#include <tinyformat.h>
1515
#include <util/fs.h>
16-
#include <util/getuniquepath.h>
1716
#include <util/syserror.h>
1817

1918
#include <cerrno>
@@ -94,19 +93,6 @@ void ReleaseDirectoryLocks()
9493
dir_locks.clear();
9594
}
9695

97-
bool DirIsWritable(const fs::path& directory)
98-
{
99-
fs::path tmpFile = GetUniquePath(directory);
100-
101-
FILE* file = fsbridge::fopen(tmpFile, "a");
102-
if (!file) return false;
103-
104-
fclose(file);
105-
remove(tmpFile);
106-
107-
return true;
108-
}
109-
11096
bool CheckDiskSpace(const fs::path& dir, uint64_t additional_bytes)
11197
{
11298
constexpr uint64_t min_disk_space = 52428800; // 50 MiB

src/util/fs_helpers.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ enum class LockResult {
4444
[[nodiscard]] LockResult LockDirectory(const fs::path& directory, const fs::path& lockfile_name, bool probe_only = false);
4545
} // namespace util
4646
void UnlockDirectory(const fs::path& directory, const fs::path& lockfile_name);
47-
bool DirIsWritable(const fs::path& directory);
4847
bool CheckDiskSpace(const fs::path& dir, uint64_t additional_bytes = 0);
4948

5049
/** Get the size of a file by scanning it.

src/util/getuniquepath.cpp

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/util/getuniquepath.h

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)