Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions include/bitcoin/database/boost.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,11 @@ inline file_handle_t open_existing_file(
const std::filesystem::path& file) NOEXCEPT
{
constexpr auto mode = interprocess::read_write;
#if defined(HAVE_MSC)
const auto filename = system::to_extended_path(file);
#else
const auto filename = file;
#endif
const auto filename = system::extended_path(file);

// Does not throw (unannotated).
BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)
return ipcdetail::open_existing_file(file.string().c_str(), mode);
return ipcdetail::open_existing_file(filename.c_str(), mode);
BC_POP_WARNING()
}

Expand Down
2 changes: 2 additions & 0 deletions include/bitcoin/database/tables/names.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ namespace libbitcoin {
namespace database {
namespace schema {

/// These should be ASCII only.

namespace dir
{
constexpr auto heads = "heads";
Expand Down
31 changes: 17 additions & 14 deletions src/file/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,18 @@ BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)

inline path trim(const path& value) NOEXCEPT
{
static const string_list trims{ "/", "\\", "\x20" };

// Trailing slash may cause successful create_directories returning false.
return system::trim_right_copy(value.string(), { "/", "\\", "\x20" });
return to_path(trim_right_copy(from_path(value), trims));
}

// We don't use ec because it gets set (not found) when false, but no way to
// differentiate from false with failure code (and never a code on success).
bool is_directory(const path& directory) NOEXCEPT
{
code ec{ system::error::errorno_t::no_error };
return std::filesystem::is_directory(system::to_extended_path(directory), ec);
return std::filesystem::is_directory(system::extended_path(directory), ec);
}

bool clear_directory(const path& directory) NOEXCEPT
Expand All @@ -64,7 +66,7 @@ bool clear_directory(const path& directory) NOEXCEPT
code clear_directory_ex(const path& directory) NOEXCEPT
{
code ec{ system::error::errorno_t::no_error };
const auto path = system::to_extended_path(directory);
const auto path = system::extended_path(directory);
std::filesystem::remove_all(path, ec);
if (ec) return ec;
std::filesystem::create_directories(path, ec);
Expand All @@ -79,7 +81,7 @@ bool create_directory(const path& directory) NOEXCEPT
code create_directory_ex(const path& directory) NOEXCEPT
{
code ec{ system::error::errorno_t::no_error };
const auto path = system::to_extended_path(trim(directory));
const auto path = system::extended_path(trim(directory));
const auto created = std::filesystem::create_directories(path, ec);
if (ec || created) return ec;
return system::error::errorno_t::is_a_directory;
Expand Down Expand Up @@ -182,7 +184,7 @@ bool remove(const path& name) NOEXCEPT
code remove_ex(const path& name) NOEXCEPT
{
code ec{ system::error::errorno_t::no_error };
std::filesystem::remove(system::to_extended_path(name), ec);
std::filesystem::remove(system::extended_path(name), ec);
return ec;
}

Expand All @@ -196,8 +198,8 @@ bool rename(const path& from, const path& to) NOEXCEPT
code rename_ex(const path& from, const path& to) NOEXCEPT
{
code ec{ system::error::errorno_t::no_error };
std::filesystem::rename(system::to_extended_path(from),
system::to_extended_path(to), ec);
std::filesystem::rename(system::extended_path(from),
system::extended_path(to), ec);

return ec;
}
Expand All @@ -212,8 +214,8 @@ bool copy(const path& from, const path& to) NOEXCEPT
code copy_ex(const path& from, const path& to) NOEXCEPT
{
code ec{ system::error::errorno_t::no_error };
std::filesystem::copy_file(system::to_extended_path(from),
system::to_extended_path(to), ec);
std::filesystem::copy_file(system::extended_path(from),
system::extended_path(to), ec);

return ec;
}
Expand All @@ -234,8 +236,8 @@ code copy_directory_ex(const path& from, const path& to) NOEXCEPT
return system::error::errorno_t::not_a_directory;

code ec{ system::error::errorno_t::no_error };
std::filesystem::copy(system::to_extended_path(from),
system::to_extended_path(to), ec);
std::filesystem::copy(system::extended_path(from),
system::extended_path(to), ec);

return ec;
}
Expand All @@ -250,7 +252,7 @@ code copy_directory_ex(const path& from, const path& to) NOEXCEPT

int open(const path& filename, bool MSC_OR_NOAPPLE(random)) NOEXCEPT
{
const auto path = system::to_extended_path(filename);
const auto path = system::extended_path(filename);
int file_descriptor{};

#if defined(HAVE_MSC)
Expand Down Expand Up @@ -371,7 +373,7 @@ code size_ex(size_t& out, const std::filesystem::path& filename) NOEXCEPT
{
code ec{ system::error::errorno_t::no_error };
const auto size = std::filesystem::file_size(
to_extended_path(filename), ec);
system::extended_path(filename), ec);

if (ec) return ec;
if (is_limited<size_t>(size))
Expand All @@ -389,7 +391,8 @@ bool space(size_t& out, const path& filename) NOEXCEPT
code space_ex(size_t& out, const path& filename) NOEXCEPT
{
code ec{ system::error::errorno_t::no_error };
const auto space = std::filesystem::space(to_extended_path(filename), ec);
const auto space = std::filesystem::space(
system::extended_path(filename), ec);
if (ec) return ec;
if (is_limited<size_t>(space.available))
return system::error::errorno_t::value_too_large;
Expand Down
2 changes: 1 addition & 1 deletion src/locks/file_lock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bool file_lock::destroy() NOEXCEPT
// remove returns false if file did not exist though error_code is false if
// file did not exist. use of error_code overload also precludes exception.
std::error_code ec;
std::filesystem::remove(system::to_extended_path(file_), ec);
std::filesystem::remove(system::extended_path(file_), ec);
return !ec;
}

Expand Down
20 changes: 1 addition & 19 deletions test/file/rotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,7 @@
*/
#include "../test.hpp"

struct rotator_setup_fixture
{
DELETE_COPY_MOVE(rotator_setup_fixture);
BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)

rotator_setup_fixture() NOEXCEPT
{
BOOST_REQUIRE(test::clear(test::directory));
}

~rotator_setup_fixture() NOEXCEPT
{
BOOST_REQUIRE(test::clear(test::directory));
}

BC_POP_WARNING()
};

BOOST_FIXTURE_TEST_SUITE(rotator_tests, rotator_setup_fixture)
BOOST_FIXTURE_TEST_SUITE(rotator_tests, test::directory_setup_fixture)

// ostream instance.
using rotate = file::stream::out::rotator;
Expand Down
20 changes: 1 addition & 19 deletions test/file/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,7 @@
*/
#include "../test.hpp"

struct file_utilities_setup_fixture
{
DELETE_COPY_MOVE(file_utilities_setup_fixture);
BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)

file_utilities_setup_fixture() NOEXCEPT
{
BOOST_REQUIRE(test::clear(test::directory));
}

~file_utilities_setup_fixture() NOEXCEPT
{
BOOST_REQUIRE(test::clear(test::directory));
}

BC_POP_WARNING()
};

BOOST_FIXTURE_TEST_SUITE(file_utilities_tests, file_utilities_setup_fixture)
BOOST_FIXTURE_TEST_SUITE(file_utilities_tests, test::directory_setup_fixture)

using namespace system;
static_assert(file::invalid == -1);
Expand Down
15 changes: 1 addition & 14 deletions test/locks/file_lock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,7 @@
*/
#include "../test.hpp"

struct file_lock_setup_fixture
{
file_lock_setup_fixture() noexcept
{
BOOST_REQUIRE(test::clear(test::directory));
}

~file_lock_setup_fixture() noexcept
{
BOOST_REQUIRE(test::clear(test::directory));
}
};

BOOST_FIXTURE_TEST_SUITE(file_lock_tests, file_lock_setup_fixture)
BOOST_FIXTURE_TEST_SUITE(file_lock_tests, test::directory_setup_fixture)

class access final
: public file_lock
Expand Down
15 changes: 1 addition & 14 deletions test/locks/flush_lock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,7 @@
*/
#include "../test.hpp"

struct flush_lock_setup_fixture
{
flush_lock_setup_fixture() noexcept
{
BOOST_REQUIRE(test::clear(test::directory));
}

~flush_lock_setup_fixture() noexcept
{
BOOST_REQUIRE(test::clear(test::directory));
}
};

BOOST_FIXTURE_TEST_SUITE(flush_lock_tests, flush_lock_setup_fixture)
BOOST_FIXTURE_TEST_SUITE(flush_lock_tests, test::directory_setup_fixture)

BOOST_AUTO_TEST_CASE(flush_lock__construct__file__expected)
{
Expand Down
15 changes: 1 addition & 14 deletions test/locks/interprocess_lock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,7 @@
*/
#include "../test.hpp"

struct interprocess_lock_setup_fixture
{
interprocess_lock_setup_fixture() noexcept
{
BOOST_REQUIRE(test::clear(test::directory));
}

~interprocess_lock_setup_fixture() noexcept
{
BOOST_REQUIRE(test::clear(test::directory));
}
};

BOOST_FIXTURE_TEST_SUITE(interprocess_lock_tests, interprocess_lock_setup_fixture)
BOOST_FIXTURE_TEST_SUITE(interprocess_lock_tests, test::directory_setup_fixture)

BOOST_AUTO_TEST_CASE(interprocess_lock__construct__file__expected)
{
Expand Down
20 changes: 1 addition & 19 deletions test/memory/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,7 @@
// error::load_failure, error::flush_failure, error::unload_failure codes, but
// don't want to make this class virtual.

struct map_setup_fixture
{
DELETE_COPY_MOVE(map_setup_fixture);
BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)

map_setup_fixture() NOEXCEPT
{
BOOST_REQUIRE(test::clear(test::directory));
}

~map_setup_fixture() NOEXCEPT
{
BOOST_REQUIRE(test::clear(test::directory));
}

BC_POP_WARNING()
};

BOOST_FIXTURE_TEST_SUITE(map_tests, map_setup_fixture)
BOOST_FIXTURE_TEST_SUITE(map_tests, test::directory_setup_fixture)

BOOST_AUTO_TEST_CASE(map__file__always__expected)
{
Expand Down
20 changes: 1 addition & 19 deletions test/query/archive_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,7 @@
#include "../mocks/blocks.hpp"
#include "../mocks/chunk_store.hpp"

struct query_archive_read_setup_fixture
{
DELETE_COPY_MOVE(query_archive_read_setup_fixture);
BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)

query_archive_read_setup_fixture() NOEXCEPT
{
BOOST_REQUIRE(test::clear(test::directory));
}

~query_archive_read_setup_fixture() NOEXCEPT
{
BOOST_REQUIRE(test::clear(test::directory));
}

BC_POP_WARNING()
};

BOOST_FIXTURE_TEST_SUITE(query_archive_read_tests, query_archive_read_setup_fixture)
BOOST_FIXTURE_TEST_SUITE(query_archive_read_tests, test::directory_setup_fixture)

////const auto events_handler = [](auto, auto) {};

Expand Down
20 changes: 1 addition & 19 deletions test/query/archive_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,7 @@
#include "../mocks/blocks.hpp"
#include "../mocks/chunk_store.hpp"

struct query_archive_write_setup_fixture
{
DELETE_COPY_MOVE(query_archive_write_setup_fixture);
BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)

query_archive_write_setup_fixture() NOEXCEPT
{
BOOST_REQUIRE(test::clear(test::directory));
}

~query_archive_write_setup_fixture() NOEXCEPT
{
BOOST_REQUIRE(test::clear(test::directory));
}

BC_POP_WARNING()
};

BOOST_FIXTURE_TEST_SUITE(query_archive_write_tests, query_archive_write_setup_fixture)
BOOST_FIXTURE_TEST_SUITE(query_archive_write_tests, test::directory_setup_fixture)

// ensure context::flags is same size as chain_context::flags.
static_assert(is_same_type<database::context::flag_t::integer, decltype(system::chain::context{}.flags)>);
Expand Down
20 changes: 1 addition & 19 deletions test/query/confirm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,7 @@
#include "../mocks/blocks.hpp"
#include "../mocks/chunk_store.hpp"

struct query_confirm_setup_fixture
{
DELETE_COPY_MOVE(query_confirm_setup_fixture);
BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)

query_confirm_setup_fixture() NOEXCEPT
{
BOOST_REQUIRE(test::clear(test::directory));
}

~query_confirm_setup_fixture() NOEXCEPT
{
BOOST_REQUIRE(test::clear(test::directory));
}

BC_POP_WARNING()
};

BOOST_FIXTURE_TEST_SUITE(query_confirm_tests, query_confirm_setup_fixture)
BOOST_FIXTURE_TEST_SUITE(query_confirm_tests, test::directory_setup_fixture)

// nop event handler.
const auto events_handler = [](auto, auto) {};
Expand Down
20 changes: 1 addition & 19 deletions test/query/consensus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,7 @@
#include "../mocks/blocks.hpp"
#include "../mocks/chunk_store.hpp"

struct query_consensus_setup_fixture
{
DELETE_COPY_MOVE(query_consensus_setup_fixture);
BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)

query_consensus_setup_fixture() NOEXCEPT
{
BOOST_REQUIRE(test::clear(test::directory));
}

~query_consensus_setup_fixture() NOEXCEPT
{
BOOST_REQUIRE(test::clear(test::directory));
}

BC_POP_WARNING()
};

BOOST_FIXTURE_TEST_SUITE(query_consensus_tests, query_consensus_setup_fixture)
BOOST_FIXTURE_TEST_SUITE(query_consensus_tests, test::directory_setup_fixture)

////const auto events_handler = [](auto, auto) {};

Expand Down
Loading
Loading