archive_r_ruby 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/{LICENSE → LICENSE.txt} +77 -77
- data/README.md +103 -103
- data/ext/archive_r/Makefile +48 -45
- data/ext/archive_r/archive_r-x64-mingw-ucrt.def +2 -0
- data/ext/archive_r/archive_r_ext.cc +1106 -1106
- data/ext/archive_r/archive_r_ext.o +0 -0
- data/ext/archive_r/extconf.rb +120 -120
- data/ext/archive_r/mkmf.log +23 -18
- data/ext/archive_r/vendor/archive_r/LICENSE.txt +77 -77
- data/ext/archive_r/vendor/archive_r/include/archive_r/data_stream.h +52 -52
- data/ext/archive_r/vendor/archive_r/include/archive_r/entry.h +166 -166
- data/ext/archive_r/vendor/archive_r/include/archive_r/entry_fault.h +34 -34
- data/ext/archive_r/vendor/archive_r/include/archive_r/entry_metadata.h +56 -56
- data/ext/archive_r/vendor/archive_r/include/archive_r/multi_volume_stream_base.h +46 -46
- data/ext/archive_r/vendor/archive_r/include/archive_r/path_hierarchy.h +109 -109
- data/ext/archive_r/vendor/archive_r/include/archive_r/path_hierarchy_utils.h +37 -37
- data/ext/archive_r/vendor/archive_r/include/archive_r/platform_compat.h +19 -19
- data/ext/archive_r/vendor/archive_r/include/archive_r/traverser.h +122 -122
- data/ext/archive_r/vendor/archive_r/src/archive_stack_cursor.cc +330 -330
- data/ext/archive_r/vendor/archive_r/src/archive_stack_cursor.h +97 -97
- data/ext/archive_r/vendor/archive_r/src/archive_stack_orchestrator.cc +162 -162
- data/ext/archive_r/vendor/archive_r/src/archive_stack_orchestrator.h +54 -54
- data/ext/archive_r/vendor/archive_r/src/archive_type.cc +552 -552
- data/ext/archive_r/vendor/archive_r/src/archive_type.h +77 -77
- data/ext/archive_r/vendor/archive_r/src/data_stream.cc +35 -35
- data/ext/archive_r/vendor/archive_r/src/entry.cc +253 -253
- data/ext/archive_r/vendor/archive_r/src/entry_fault.cc +26 -26
- data/ext/archive_r/vendor/archive_r/src/entry_fault_error.cc +54 -54
- data/ext/archive_r/vendor/archive_r/src/entry_fault_error.h +32 -32
- data/ext/archive_r/vendor/archive_r/src/entry_impl.h +57 -57
- data/ext/archive_r/vendor/archive_r/src/multi_volume_manager.cc +81 -81
- data/ext/archive_r/vendor/archive_r/src/multi_volume_manager.h +41 -41
- data/ext/archive_r/vendor/archive_r/src/multi_volume_stream_base.cc +199 -199
- data/ext/archive_r/vendor/archive_r/src/path_hierarchy.cc +151 -151
- data/ext/archive_r/vendor/archive_r/src/path_hierarchy_utils.cc +304 -304
- data/ext/archive_r/vendor/archive_r/src/simple_profiler.h +120 -120
- data/ext/archive_r/vendor/archive_r/src/system_file_stream.cc +295 -295
- data/ext/archive_r/vendor/archive_r/src/system_file_stream.h +46 -46
- data/ext/archive_r/vendor/archive_r/src/traverser.cc +314 -314
- data/lib/archive_r.rb +105 -105
- metadata +11 -8
- data/ext/archive_r/archive_r.bundle +0 -0
|
@@ -1,151 +1,151 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
// Copyright (c) 2025 archive_r Team
|
|
3
|
-
|
|
4
|
-
#include "archive_r/path_hierarchy.h"
|
|
5
|
-
|
|
6
|
-
#include <string>
|
|
7
|
-
#include <utility>
|
|
8
|
-
#include <vector>
|
|
9
|
-
|
|
10
|
-
namespace archive_r {
|
|
11
|
-
namespace {
|
|
12
|
-
|
|
13
|
-
int entry_type_rank(const PathEntry &entry) {
|
|
14
|
-
if (entry.is_single()) {
|
|
15
|
-
return 0;
|
|
16
|
-
}
|
|
17
|
-
if (entry.is_multi_volume()) {
|
|
18
|
-
return 1;
|
|
19
|
-
}
|
|
20
|
-
return 2;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
int compare_node_lists_impl(const PathEntry::NodeList &lhs, const PathEntry::NodeList &rhs);
|
|
24
|
-
|
|
25
|
-
int compare_entries_impl(const PathEntry &lhs, const PathEntry &rhs) {
|
|
26
|
-
const int lhs_rank = entry_type_rank(lhs);
|
|
27
|
-
const int rhs_rank = entry_type_rank(rhs);
|
|
28
|
-
if (lhs_rank != rhs_rank) {
|
|
29
|
-
return lhs_rank < rhs_rank ? -1 : 1;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (lhs.is_single()) {
|
|
33
|
-
const auto &lval = lhs.single_value();
|
|
34
|
-
const auto &rval = rhs.single_value();
|
|
35
|
-
if (lval < rval) {
|
|
36
|
-
return -1;
|
|
37
|
-
}
|
|
38
|
-
if (rval < lval) {
|
|
39
|
-
return 1;
|
|
40
|
-
}
|
|
41
|
-
return 0;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (lhs.is_multi_volume()) {
|
|
45
|
-
const auto &lparts = lhs.multi_volume_parts();
|
|
46
|
-
const auto &rparts = rhs.multi_volume_parts();
|
|
47
|
-
if (lparts.ordering != rparts.ordering) {
|
|
48
|
-
return static_cast<int>(lparts.ordering) < static_cast<int>(rparts.ordering) ? -1 : 1;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const std::size_t lsize = lparts.values.size();
|
|
52
|
-
const std::size_t rsize = rparts.values.size();
|
|
53
|
-
const std::size_t compare_count = lsize < rsize ? lsize : rsize;
|
|
54
|
-
for (std::size_t i = 0; i < compare_count; ++i) {
|
|
55
|
-
const std::string &lvalue = lparts.values[i];
|
|
56
|
-
const std::string &rvalue = rparts.values[i];
|
|
57
|
-
if (lvalue < rvalue) {
|
|
58
|
-
return -1;
|
|
59
|
-
}
|
|
60
|
-
if (rvalue < lvalue) {
|
|
61
|
-
return 1;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (lsize != rsize) {
|
|
66
|
-
return lsize < rsize ? -1 : 1;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return 0;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return compare_node_lists_impl(lhs.nested_nodes(), rhs.nested_nodes());
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
int compare_node_lists_impl(const PathEntry::NodeList &lhs, const PathEntry::NodeList &rhs) {
|
|
76
|
-
const std::size_t lsize = lhs.size();
|
|
77
|
-
const std::size_t rsize = rhs.size();
|
|
78
|
-
const std::size_t compare_count = lsize < rsize ? lsize : rsize;
|
|
79
|
-
for (std::size_t i = 0; i < compare_count; ++i) {
|
|
80
|
-
const int cmp = compare_entries_impl(lhs[i], rhs[i]);
|
|
81
|
-
if (cmp != 0) {
|
|
82
|
-
return cmp;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (lsize != rsize) {
|
|
86
|
-
return lsize < rsize ? -1 : 1;
|
|
87
|
-
}
|
|
88
|
-
return 0;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
int compare_hierarchies_impl(const PathHierarchy &lhs, const PathHierarchy &rhs) {
|
|
92
|
-
const std::size_t lhs_size = lhs.size();
|
|
93
|
-
const std::size_t rhs_size = rhs.size();
|
|
94
|
-
const std::size_t compare_count = lhs_size < rhs_size ? lhs_size : rhs_size;
|
|
95
|
-
for (std::size_t i = 0; i < compare_count; ++i) {
|
|
96
|
-
const int cmp = compare_entries_impl(lhs[i], rhs[i]);
|
|
97
|
-
if (cmp != 0) {
|
|
98
|
-
return cmp;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (lhs_size != rhs_size) {
|
|
102
|
-
return lhs_size < rhs_size ? -1 : 1;
|
|
103
|
-
}
|
|
104
|
-
return 0;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
bool entries_equal_impl(const PathEntry &lhs, const PathEntry &rhs) { return compare_entries_impl(lhs, rhs) == 0; }
|
|
108
|
-
|
|
109
|
-
bool hierarchies_equal_impl(const PathHierarchy &lhs, const PathHierarchy &rhs) { return compare_hierarchies_impl(lhs, rhs) == 0; }
|
|
110
|
-
|
|
111
|
-
} // namespace
|
|
112
|
-
|
|
113
|
-
int compare_entries(const PathEntry &lhs, const PathEntry &rhs) { return compare_entries_impl(lhs, rhs); }
|
|
114
|
-
|
|
115
|
-
int compare_hierarchies(const PathHierarchy &lhs, const PathHierarchy &rhs) { return compare_hierarchies_impl(lhs, rhs); }
|
|
116
|
-
|
|
117
|
-
bool entries_equal(const PathEntry &lhs, const PathEntry &rhs) { return entries_equal_impl(lhs, rhs); }
|
|
118
|
-
|
|
119
|
-
bool hierarchies_equal(const PathHierarchy &lhs, const PathHierarchy &rhs) { return hierarchies_equal_impl(lhs, rhs); }
|
|
120
|
-
|
|
121
|
-
bool PathHierarchyLess::operator()(const PathHierarchy &lhs, const PathHierarchy &rhs) const { return compare_hierarchies(lhs, rhs) < 0; }
|
|
122
|
-
|
|
123
|
-
PathHierarchy make_single_path(const std::string &root) {
|
|
124
|
-
PathHierarchy hierarchy;
|
|
125
|
-
hierarchy.emplace_back(PathEntry::single(root));
|
|
126
|
-
return hierarchy;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
void append_single(PathHierarchy &hierarchy, std::string value) { hierarchy.emplace_back(PathEntry::single(std::move(value))); }
|
|
130
|
-
|
|
131
|
-
void append_multi_volume(PathHierarchy &hierarchy, std::vector<std::string> parts, PathEntry::Parts::Ordering ordering) {
|
|
132
|
-
hierarchy.emplace_back(PathEntry::multi_volume(std::move(parts), ordering));
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
PathHierarchy pathhierarchy_prefix_until(const PathHierarchy &hierarchy, size_t inclusive_index) {
|
|
136
|
-
if (hierarchy.empty() || inclusive_index >= hierarchy.size()) {
|
|
137
|
-
return {};
|
|
138
|
-
}
|
|
139
|
-
const auto prefix_end = hierarchy.begin() + static_cast<PathHierarchy::difference_type>(inclusive_index + 1);
|
|
140
|
-
return PathHierarchy(hierarchy.begin(), prefix_end);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
PathHierarchy parent_hierarchy(const PathHierarchy &hierarchy) {
|
|
144
|
-
if (hierarchy.size() <= 1) {
|
|
145
|
-
return {};
|
|
146
|
-
}
|
|
147
|
-
return pathhierarchy_prefix_until(hierarchy, hierarchy.size() - 2);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
} // namespace archive_r
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copyright (c) 2025 archive_r Team
|
|
3
|
+
|
|
4
|
+
#include "archive_r/path_hierarchy.h"
|
|
5
|
+
|
|
6
|
+
#include <string>
|
|
7
|
+
#include <utility>
|
|
8
|
+
#include <vector>
|
|
9
|
+
|
|
10
|
+
namespace archive_r {
|
|
11
|
+
namespace {
|
|
12
|
+
|
|
13
|
+
int entry_type_rank(const PathEntry &entry) {
|
|
14
|
+
if (entry.is_single()) {
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
17
|
+
if (entry.is_multi_volume()) {
|
|
18
|
+
return 1;
|
|
19
|
+
}
|
|
20
|
+
return 2;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
int compare_node_lists_impl(const PathEntry::NodeList &lhs, const PathEntry::NodeList &rhs);
|
|
24
|
+
|
|
25
|
+
int compare_entries_impl(const PathEntry &lhs, const PathEntry &rhs) {
|
|
26
|
+
const int lhs_rank = entry_type_rank(lhs);
|
|
27
|
+
const int rhs_rank = entry_type_rank(rhs);
|
|
28
|
+
if (lhs_rank != rhs_rank) {
|
|
29
|
+
return lhs_rank < rhs_rank ? -1 : 1;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (lhs.is_single()) {
|
|
33
|
+
const auto &lval = lhs.single_value();
|
|
34
|
+
const auto &rval = rhs.single_value();
|
|
35
|
+
if (lval < rval) {
|
|
36
|
+
return -1;
|
|
37
|
+
}
|
|
38
|
+
if (rval < lval) {
|
|
39
|
+
return 1;
|
|
40
|
+
}
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (lhs.is_multi_volume()) {
|
|
45
|
+
const auto &lparts = lhs.multi_volume_parts();
|
|
46
|
+
const auto &rparts = rhs.multi_volume_parts();
|
|
47
|
+
if (lparts.ordering != rparts.ordering) {
|
|
48
|
+
return static_cast<int>(lparts.ordering) < static_cast<int>(rparts.ordering) ? -1 : 1;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const std::size_t lsize = lparts.values.size();
|
|
52
|
+
const std::size_t rsize = rparts.values.size();
|
|
53
|
+
const std::size_t compare_count = lsize < rsize ? lsize : rsize;
|
|
54
|
+
for (std::size_t i = 0; i < compare_count; ++i) {
|
|
55
|
+
const std::string &lvalue = lparts.values[i];
|
|
56
|
+
const std::string &rvalue = rparts.values[i];
|
|
57
|
+
if (lvalue < rvalue) {
|
|
58
|
+
return -1;
|
|
59
|
+
}
|
|
60
|
+
if (rvalue < lvalue) {
|
|
61
|
+
return 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (lsize != rsize) {
|
|
66
|
+
return lsize < rsize ? -1 : 1;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return compare_node_lists_impl(lhs.nested_nodes(), rhs.nested_nodes());
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
int compare_node_lists_impl(const PathEntry::NodeList &lhs, const PathEntry::NodeList &rhs) {
|
|
76
|
+
const std::size_t lsize = lhs.size();
|
|
77
|
+
const std::size_t rsize = rhs.size();
|
|
78
|
+
const std::size_t compare_count = lsize < rsize ? lsize : rsize;
|
|
79
|
+
for (std::size_t i = 0; i < compare_count; ++i) {
|
|
80
|
+
const int cmp = compare_entries_impl(lhs[i], rhs[i]);
|
|
81
|
+
if (cmp != 0) {
|
|
82
|
+
return cmp;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (lsize != rsize) {
|
|
86
|
+
return lsize < rsize ? -1 : 1;
|
|
87
|
+
}
|
|
88
|
+
return 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
int compare_hierarchies_impl(const PathHierarchy &lhs, const PathHierarchy &rhs) {
|
|
92
|
+
const std::size_t lhs_size = lhs.size();
|
|
93
|
+
const std::size_t rhs_size = rhs.size();
|
|
94
|
+
const std::size_t compare_count = lhs_size < rhs_size ? lhs_size : rhs_size;
|
|
95
|
+
for (std::size_t i = 0; i < compare_count; ++i) {
|
|
96
|
+
const int cmp = compare_entries_impl(lhs[i], rhs[i]);
|
|
97
|
+
if (cmp != 0) {
|
|
98
|
+
return cmp;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (lhs_size != rhs_size) {
|
|
102
|
+
return lhs_size < rhs_size ? -1 : 1;
|
|
103
|
+
}
|
|
104
|
+
return 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
bool entries_equal_impl(const PathEntry &lhs, const PathEntry &rhs) { return compare_entries_impl(lhs, rhs) == 0; }
|
|
108
|
+
|
|
109
|
+
bool hierarchies_equal_impl(const PathHierarchy &lhs, const PathHierarchy &rhs) { return compare_hierarchies_impl(lhs, rhs) == 0; }
|
|
110
|
+
|
|
111
|
+
} // namespace
|
|
112
|
+
|
|
113
|
+
int compare_entries(const PathEntry &lhs, const PathEntry &rhs) { return compare_entries_impl(lhs, rhs); }
|
|
114
|
+
|
|
115
|
+
int compare_hierarchies(const PathHierarchy &lhs, const PathHierarchy &rhs) { return compare_hierarchies_impl(lhs, rhs); }
|
|
116
|
+
|
|
117
|
+
bool entries_equal(const PathEntry &lhs, const PathEntry &rhs) { return entries_equal_impl(lhs, rhs); }
|
|
118
|
+
|
|
119
|
+
bool hierarchies_equal(const PathHierarchy &lhs, const PathHierarchy &rhs) { return hierarchies_equal_impl(lhs, rhs); }
|
|
120
|
+
|
|
121
|
+
bool PathHierarchyLess::operator()(const PathHierarchy &lhs, const PathHierarchy &rhs) const { return compare_hierarchies(lhs, rhs) < 0; }
|
|
122
|
+
|
|
123
|
+
PathHierarchy make_single_path(const std::string &root) {
|
|
124
|
+
PathHierarchy hierarchy;
|
|
125
|
+
hierarchy.emplace_back(PathEntry::single(root));
|
|
126
|
+
return hierarchy;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
void append_single(PathHierarchy &hierarchy, std::string value) { hierarchy.emplace_back(PathEntry::single(std::move(value))); }
|
|
130
|
+
|
|
131
|
+
void append_multi_volume(PathHierarchy &hierarchy, std::vector<std::string> parts, PathEntry::Parts::Ordering ordering) {
|
|
132
|
+
hierarchy.emplace_back(PathEntry::multi_volume(std::move(parts), ordering));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
PathHierarchy pathhierarchy_prefix_until(const PathHierarchy &hierarchy, size_t inclusive_index) {
|
|
136
|
+
if (hierarchy.empty() || inclusive_index >= hierarchy.size()) {
|
|
137
|
+
return {};
|
|
138
|
+
}
|
|
139
|
+
const auto prefix_end = hierarchy.begin() + static_cast<PathHierarchy::difference_type>(inclusive_index + 1);
|
|
140
|
+
return PathHierarchy(hierarchy.begin(), prefix_end);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
PathHierarchy parent_hierarchy(const PathHierarchy &hierarchy) {
|
|
144
|
+
if (hierarchy.size() <= 1) {
|
|
145
|
+
return {};
|
|
146
|
+
}
|
|
147
|
+
return pathhierarchy_prefix_until(hierarchy, hierarchy.size() - 2);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
} // namespace archive_r
|