refactor(chmod_transformer): move to internal namespace

This commit is contained in:
Marcus Holland-Moritz 2024-07-29 00:05:27 +02:00
parent 620a353cdb
commit 2b94aeae88
5 changed files with 17 additions and 16 deletions

View File

@ -645,7 +645,6 @@ list(APPEND LIBDWARFS_WRITER_SRC
src/dwarfs/categorizer.cpp src/dwarfs/categorizer.cpp
src/dwarfs/category_parser.cpp src/dwarfs/category_parser.cpp
src/dwarfs/chmod_entry_transformer.cpp src/dwarfs/chmod_entry_transformer.cpp
src/dwarfs/chmod_transformer.cpp
src/dwarfs/console_writer.cpp src/dwarfs/console_writer.cpp
src/dwarfs/entry.cpp src/dwarfs/entry.cpp
src/dwarfs/filesystem_block_category_resolver.cpp src/dwarfs/filesystem_block_category_resolver.cpp
@ -655,6 +654,7 @@ list(APPEND LIBDWARFS_WRITER_SRC
src/dwarfs/fragment_order_parser.cpp src/dwarfs/fragment_order_parser.cpp
src/dwarfs/inode_fragments.cpp src/dwarfs/inode_fragments.cpp
src/dwarfs/internal/block_manager.cpp src/dwarfs/internal/block_manager.cpp
src/dwarfs/internal/chmod_transformer.cpp
src/dwarfs/internal/file_scanner.cpp src/dwarfs/internal/file_scanner.cpp
src/dwarfs/internal/fragment_chunkable.cpp src/dwarfs/internal/fragment_chunkable.cpp
src/dwarfs/internal/global_entry_data.cpp src/dwarfs/internal/global_entry_data.cpp

View File

@ -27,7 +27,7 @@
#include <dwarfs/file_stat.h> #include <dwarfs/file_stat.h>
namespace dwarfs { namespace dwarfs::internal {
class chmod_transformer { class chmod_transformer {
public: public:
@ -51,4 +51,4 @@ class chmod_transformer {
std::unique_ptr<impl> impl_; std::unique_ptr<impl> impl_;
}; };
} // namespace dwarfs } // namespace dwarfs::internal

View File

@ -20,12 +20,13 @@
*/ */
#include <dwarfs/chmod_entry_transformer.h> #include <dwarfs/chmod_entry_transformer.h>
#include <dwarfs/chmod_transformer.h>
#include <dwarfs/entry_interface.h> #include <dwarfs/entry_interface.h>
#include <dwarfs/internal/chmod_transformer.h>
namespace dwarfs { namespace dwarfs {
namespace { namespace internal {
class chmod_entry_transformer : public entry_transformer { class chmod_entry_transformer : public entry_transformer {
public: public:
@ -43,12 +44,12 @@ class chmod_entry_transformer : public entry_transformer {
chmod_transformer transformer_; chmod_transformer transformer_;
}; };
} // namespace } // namespace internal
std::unique_ptr<entry_transformer> std::unique_ptr<entry_transformer>
create_chmod_entry_transformer(std::string_view spec, create_chmod_entry_transformer(std::string_view spec,
file_stat::mode_type umask) { file_stat::mode_type umask) {
return std::make_unique<chmod_entry_transformer>(spec, umask); return std::make_unique<internal::chmod_entry_transformer>(spec, umask);
} }
} // namespace dwarfs } // namespace dwarfs

View File

@ -25,9 +25,9 @@
#include <fmt/format.h> #include <fmt/format.h>
#include <dwarfs/chmod_transformer.h> #include <dwarfs/internal/chmod_transformer.h>
namespace dwarfs { namespace dwarfs::internal {
namespace fs = std::filesystem; namespace fs = std::filesystem;
@ -341,4 +341,4 @@ chmod_transformer_::transform(mode_type mode, bool isdir) const {
chmod_transformer::chmod_transformer(std::string_view spec, mode_type umask) chmod_transformer::chmod_transformer(std::string_view spec, mode_type umask)
: impl_{std::make_unique<chmod_transformer_>(spec, umask)} {} : impl_{std::make_unique<chmod_transformer_>(spec, umask)} {}
} // namespace dwarfs } // namespace dwarfs::internal

View File

@ -30,7 +30,7 @@
#include <range/v3/view/enumerate.hpp> #include <range/v3/view/enumerate.hpp>
#include <dwarfs/chmod_transformer.h> #include <dwarfs/internal/chmod_transformer.h>
using namespace dwarfs; using namespace dwarfs;
namespace fs = std::filesystem; namespace fs = std::filesystem;
@ -78,7 +78,7 @@ std::ostream& operator<<(std::ostream& os, octal_mode const& mode) {
TEST(chmod_transformer, basic) { TEST(chmod_transformer, basic) {
{ {
chmod_transformer ct{"u+x", 0022}; internal::chmod_transformer ct{"u+x", 0022};
EXPECT_EQ_MODE(ct.transform(0644, false), 0744); EXPECT_EQ_MODE(ct.transform(0644, false), 0744);
EXPECT_EQ_MODE(ct.transform(0755, false), 0755); EXPECT_EQ_MODE(ct.transform(0755, false), 0755);
EXPECT_EQ_MODE(ct.transform(0644, true), 0744); EXPECT_EQ_MODE(ct.transform(0644, true), 0744);
@ -86,7 +86,7 @@ TEST(chmod_transformer, basic) {
} }
{ {
chmod_transformer ct{"Fu+x", 0022}; internal::chmod_transformer ct{"Fu+x", 0022};
EXPECT_EQ_MODE(ct.transform(0644, false), 0744); EXPECT_EQ_MODE(ct.transform(0644, false), 0744);
EXPECT_EQ_MODE(ct.transform(0755, false), 0755); EXPECT_EQ_MODE(ct.transform(0755, false), 0755);
EXPECT_EQ_MODE(ct.transform(0644, true), std::nullopt); EXPECT_EQ_MODE(ct.transform(0644, true), std::nullopt);
@ -94,7 +94,7 @@ TEST(chmod_transformer, basic) {
} }
{ {
chmod_transformer ct{"Du+x", 0022}; internal::chmod_transformer ct{"Du+x", 0022};
EXPECT_EQ_MODE(ct.transform(0644, false), std::nullopt); EXPECT_EQ_MODE(ct.transform(0644, false), std::nullopt);
EXPECT_EQ_MODE(ct.transform(0755, false), std::nullopt); EXPECT_EQ_MODE(ct.transform(0755, false), std::nullopt);
EXPECT_EQ_MODE(ct.transform(0644, true), 0744); EXPECT_EQ_MODE(ct.transform(0644, true), 0744);
@ -104,7 +104,7 @@ TEST(chmod_transformer, basic) {
namespace { namespace {
using mode_type = chmod_transformer::mode_type; using mode_type = internal::chmod_transformer::mode_type;
struct random_test { struct random_test {
std::string_view spec; std::string_view spec;
@ -5122,7 +5122,7 @@ constexpr std::array<random_test, 5000> const random_tests{{
TEST(chmod_transformer, random) { TEST(chmod_transformer, random) {
for (auto const& [i, t] : ranges::views::enumerate(random_tests)) { for (auto const& [i, t] : ranges::views::enumerate(random_tests)) {
chmod_transformer ct{t.spec, t.umask}; internal::chmod_transformer ct{t.spec, t.umask};
EXPECT_EQ_MODE(ct.transform(t.mode, false), t.expected) EXPECT_EQ_MODE(ct.transform(t.mode, false), t.expected)
<< "test " << i << ": " << t.spec << ", " << t.umask << ", " << t.mode << "test " << i << ": " << t.spec << ", " << t.umask << ", " << t.mode
<< ", " << t.expected; << ", " << t.expected;