archive_r_ruby 0.1.20 → 0.1.22

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -21
  3. data/NOTICE +116 -116
  4. data/README.md +106 -106
  5. data/VERSION +1 -1
  6. data/ext/archive_r/archive_r_ext.cc +1098 -1098
  7. data/ext/archive_r/extconf.rb +125 -125
  8. data/ext/archive_r/vendor/archive_r/LICENSE +21 -21
  9. data/ext/archive_r/vendor/archive_r/NOTICE +116 -116
  10. data/ext/archive_r/vendor/archive_r/include/archive_r/data_stream.h +42 -42
  11. data/ext/archive_r/vendor/archive_r/include/archive_r/entry.h +180 -180
  12. data/ext/archive_r/vendor/archive_r/include/archive_r/entry_fault.h +34 -34
  13. data/ext/archive_r/vendor/archive_r/include/archive_r/entry_metadata.h +56 -56
  14. data/ext/archive_r/vendor/archive_r/include/archive_r/multi_volume_stream_base.h +46 -46
  15. data/ext/archive_r/vendor/archive_r/include/archive_r/path_hierarchy.h +92 -92
  16. data/ext/archive_r/vendor/archive_r/include/archive_r/path_hierarchy_utils.h +36 -36
  17. data/ext/archive_r/vendor/archive_r/include/archive_r/platform_compat.h +34 -34
  18. data/ext/archive_r/vendor/archive_r/include/archive_r/traverser.h +156 -156
  19. data/ext/archive_r/vendor/archive_r/src/archive_stack_cursor.cc +300 -300
  20. data/ext/archive_r/vendor/archive_r/src/archive_stack_cursor.h +110 -110
  21. data/ext/archive_r/vendor/archive_r/src/archive_stack_orchestrator.cc +161 -161
  22. data/ext/archive_r/vendor/archive_r/src/archive_stack_orchestrator.h +53 -53
  23. data/ext/archive_r/vendor/archive_r/src/archive_type.cc +545 -545
  24. data/ext/archive_r/vendor/archive_r/src/archive_type.h +77 -77
  25. data/ext/archive_r/vendor/archive_r/src/data_stream.cc +35 -35
  26. data/ext/archive_r/vendor/archive_r/src/entry.cc +238 -238
  27. data/ext/archive_r/vendor/archive_r/src/entry_fault.cc +26 -26
  28. data/ext/archive_r/vendor/archive_r/src/entry_fault_error.cc +54 -54
  29. data/ext/archive_r/vendor/archive_r/src/entry_fault_error.h +32 -32
  30. data/ext/archive_r/vendor/archive_r/src/entry_impl.h +56 -56
  31. data/ext/archive_r/vendor/archive_r/src/multi_volume_manager.cc +76 -76
  32. data/ext/archive_r/vendor/archive_r/src/multi_volume_manager.h +39 -39
  33. data/ext/archive_r/vendor/archive_r/src/multi_volume_stream_base.cc +208 -208
  34. data/ext/archive_r/vendor/archive_r/src/path_hierarchy.cc +127 -127
  35. data/ext/archive_r/vendor/archive_r/src/path_hierarchy_utils.cc +251 -251
  36. data/ext/archive_r/vendor/archive_r/src/simple_profiler.h +109 -109
  37. data/ext/archive_r/vendor/archive_r/src/system_file_stream.cc +294 -294
  38. data/ext/archive_r/vendor/archive_r/src/system_file_stream.h +46 -46
  39. data/ext/archive_r/vendor/archive_r/src/traverser.cc +295 -295
  40. data/lib/archive_r.rb +120 -120
  41. metadata +2 -2
@@ -1,110 +1,110 @@
1
- // SPDX-License-Identifier: MIT
2
- // Copyright (c) 2025 archive_r Team
3
-
4
- #pragma once
5
-
6
- #include "archive_r/data_stream.h"
7
- #include "archive_r/multi_volume_stream_base.h"
8
- #include "archive_r/path_hierarchy.h"
9
- #include "archive_type.h"
10
- #include "entry_fault_error.h"
11
- #include <array>
12
- #include <cstddef>
13
- #include <exception>
14
- #include <memory>
15
- #include <string>
16
- #include <vector>
17
-
18
- namespace archive_r {
19
-
20
- // ============================================================================
21
- // StreamArchive Interface
22
- // ============================================================================
23
-
24
- class StreamArchive : public Archive {
25
- public:
26
- explicit StreamArchive(std::shared_ptr<IDataStream> stream, ArchiveOption options = {});
27
-
28
- ~StreamArchive() override;
29
-
30
- void open_archive() override;
31
- void rewind() override;
32
-
33
- PathHierarchy source_hierarchy() const;
34
- std::shared_ptr<StreamArchive> parent_archive() const;
35
-
36
- std::shared_ptr<IDataStream> get_stream() const { return _stream; }
37
-
38
- private:
39
- static la_ssize_t read_callback_bridge(struct archive *a, void *client_data, const void **buff);
40
- static la_int64_t seek_callback_bridge(struct archive *a, void *client_data, la_int64_t request, int whence);
41
- static la_int64_t skip_callback_bridge(struct archive *a, void *client_data, la_int64_t request);
42
-
43
- static constexpr size_t BUFFER_SIZE = 65536;
44
- std::shared_ptr<IDataStream> _stream;
45
- std::array<char, BUFFER_SIZE> _buffer;
46
- ArchiveOption _options;
47
- };
48
-
49
- // ============================================================================
50
- // EntryPayloadStream Interface
51
- // ============================================================================
52
-
53
- class EntryPayloadStream : public MultiVolumeStreamBase {
54
- public:
55
- EntryPayloadStream(std::shared_ptr<StreamArchive> parent_archive, PathHierarchy logical_path);
56
- ~EntryPayloadStream() override;
57
-
58
- std::shared_ptr<StreamArchive> parent_archive() const;
59
- void rewind() override;
60
-
61
- private:
62
- std::shared_ptr<StreamArchive> _parent_archive;
63
-
64
- void open_single_part(const PathHierarchy &single_part) override;
65
- void close_single_part() override;
66
- ssize_t read_from_single_part(void *buffer, size_t size) override;
67
- };
68
-
69
- // ============================================================================
70
- // ArchiveStackCursor Interface
71
- // ============================================================================
72
-
73
- struct ArchiveStackCursor {
74
-
75
- ArchiveStackCursor();
76
-
77
- void configure(const ArchiveOption &options);
78
- void reset();
79
- bool has_stream() const { return _current_stream != nullptr; }
80
-
81
- bool descend();
82
- bool ascend();
83
- bool next();
84
- bool synchronize_to_hierarchy(const PathHierarchy &hierarchy);
85
- ssize_t read(void *buffer, size_t len);
86
-
87
- size_t depth() const {
88
- size_t d = 0;
89
- auto a = _current_archive;
90
- while (a) {
91
- d++;
92
- a = a->parent_archive();
93
- }
94
- return d;
95
- }
96
-
97
- StreamArchive *current_archive();
98
-
99
- PathHierarchy current_entry_hierarchy();
100
-
101
- std::shared_ptr<IDataStream> create_stream(const PathHierarchy &hierarchy);
102
-
103
- ArchiveOption options_snapshot;
104
-
105
- private:
106
- std::shared_ptr<IDataStream> _current_stream;
107
- std::shared_ptr<StreamArchive> _current_archive;
108
- };
109
-
110
- } // namespace archive_r
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2025 archive_r Team
3
+
4
+ #pragma once
5
+
6
+ #include "archive_r/data_stream.h"
7
+ #include "archive_r/multi_volume_stream_base.h"
8
+ #include "archive_r/path_hierarchy.h"
9
+ #include "archive_type.h"
10
+ #include "entry_fault_error.h"
11
+ #include <array>
12
+ #include <cstddef>
13
+ #include <exception>
14
+ #include <memory>
15
+ #include <string>
16
+ #include <vector>
17
+
18
+ namespace archive_r {
19
+
20
+ // ============================================================================
21
+ // StreamArchive Interface
22
+ // ============================================================================
23
+
24
+ class StreamArchive : public Archive {
25
+ public:
26
+ explicit StreamArchive(std::shared_ptr<IDataStream> stream, ArchiveOption options = {});
27
+
28
+ ~StreamArchive() override;
29
+
30
+ void open_archive() override;
31
+ void rewind() override;
32
+
33
+ PathHierarchy source_hierarchy() const;
34
+ std::shared_ptr<StreamArchive> parent_archive() const;
35
+
36
+ std::shared_ptr<IDataStream> get_stream() const { return _stream; }
37
+
38
+ private:
39
+ static la_ssize_t read_callback_bridge(struct archive *a, void *client_data, const void **buff);
40
+ static la_int64_t seek_callback_bridge(struct archive *a, void *client_data, la_int64_t request, int whence);
41
+ static la_int64_t skip_callback_bridge(struct archive *a, void *client_data, la_int64_t request);
42
+
43
+ static constexpr size_t BUFFER_SIZE = 65536;
44
+ std::shared_ptr<IDataStream> _stream;
45
+ std::array<char, BUFFER_SIZE> _buffer;
46
+ ArchiveOption _options;
47
+ };
48
+
49
+ // ============================================================================
50
+ // EntryPayloadStream Interface
51
+ // ============================================================================
52
+
53
+ class EntryPayloadStream : public MultiVolumeStreamBase {
54
+ public:
55
+ EntryPayloadStream(std::shared_ptr<StreamArchive> parent_archive, PathHierarchy logical_path);
56
+ ~EntryPayloadStream() override;
57
+
58
+ std::shared_ptr<StreamArchive> parent_archive() const;
59
+ void rewind() override;
60
+
61
+ private:
62
+ std::shared_ptr<StreamArchive> _parent_archive;
63
+
64
+ void open_single_part(const PathHierarchy &single_part) override;
65
+ void close_single_part() override;
66
+ ssize_t read_from_single_part(void *buffer, size_t size) override;
67
+ };
68
+
69
+ // ============================================================================
70
+ // ArchiveStackCursor Interface
71
+ // ============================================================================
72
+
73
+ struct ArchiveStackCursor {
74
+
75
+ ArchiveStackCursor();
76
+
77
+ void configure(const ArchiveOption &options);
78
+ void reset();
79
+ bool has_stream() const { return _current_stream != nullptr; }
80
+
81
+ bool descend();
82
+ bool ascend();
83
+ bool next();
84
+ bool synchronize_to_hierarchy(const PathHierarchy &hierarchy);
85
+ ssize_t read(void *buffer, size_t len);
86
+
87
+ size_t depth() const {
88
+ size_t d = 0;
89
+ auto a = _current_archive;
90
+ while (a) {
91
+ d++;
92
+ a = a->parent_archive();
93
+ }
94
+ return d;
95
+ }
96
+
97
+ StreamArchive *current_archive();
98
+
99
+ PathHierarchy current_entry_hierarchy();
100
+
101
+ std::shared_ptr<IDataStream> create_stream(const PathHierarchy &hierarchy);
102
+
103
+ ArchiveOption options_snapshot;
104
+
105
+ private:
106
+ std::shared_ptr<IDataStream> _current_stream;
107
+ std::shared_ptr<StreamArchive> _current_archive;
108
+ };
109
+
110
+ } // namespace archive_r
@@ -1,161 +1,161 @@
1
- // SPDX-License-Identifier: MIT
2
- // Copyright (c) 2025 archive_r Team
3
-
4
- #include "archive_stack_orchestrator.h"
5
- #include "archive_r/entry_fault.h"
6
- #include "archive_r/path_hierarchy_utils.h"
7
- #include "system_file_stream.h"
8
-
9
- #include <algorithm>
10
- #include <cstddef>
11
- #include <cstdio>
12
- #include <exception>
13
- #include <limits>
14
- #include <memory>
15
- #include <stdexcept>
16
- #include <typeinfo>
17
- #include <utility>
18
-
19
- namespace archive_r {
20
-
21
- ArchiveStackOrchestrator::ArchiveStackOrchestrator(const ArchiveOption &options)
22
- : _archive_options(options) {
23
- _head.configure(_archive_options);
24
- }
25
-
26
- ArchiveStackOrchestrator::~ArchiveStackOrchestrator() = default;
27
-
28
- size_t ArchiveStackOrchestrator::depth() const { return _head.depth(); }
29
-
30
- StreamArchive *ArchiveStackOrchestrator::current_archive() { return _head.current_archive(); }
31
-
32
- // Drives the traversal state machine:
33
- // 1. Optionally descend into the current entry when requested.
34
- // 2. Attempt to advance within the active archive; report faults but keep looping.
35
- // 3. Drain any pending multi-volume groups before bubbling up to the parent so multipart
36
- // archives are consumed contiguously.
37
- // 4. When leaving a multi-volume context, rewind the parent archive by skipping to EOF to
38
- // avoid re-reading already processed entries.
39
- bool ArchiveStackOrchestrator::advance(bool descend_request) {
40
- bool request_descend = descend_request;
41
-
42
- while (true) {
43
- if (depth() == 0) {
44
- return false;
45
- }
46
- try {
47
- if (request_descend) {
48
- request_descend = false;
49
- _head.descend();
50
- }
51
- } catch (const EntryFaultError &error) {
52
- dispatch_fault(error.fault());
53
- continue;
54
- }
55
-
56
- try {
57
- if (_head.next()) {
58
- return true;
59
- }
60
- } catch (const EntryFaultError &error) {
61
- dispatch_fault(error.fault());
62
- continue;
63
- }
64
-
65
- try {
66
- // Consume any pending multi-volume siblings so we do not return to the parent mid-series.
67
- if (descend_pending_multi_volumes()) {
68
- continue;
69
- }
70
- } catch (const EntryFaultError &error) {
71
- dispatch_fault(error.fault());
72
- }
73
-
74
- PathHierarchy prev_ascend_hierarchy = _head.current_entry_hierarchy();
75
- _head.ascend();
76
-
77
- if (!pathhierarchy_is_multivolume(prev_ascend_hierarchy)) {
78
- continue;
79
- }
80
-
81
- try {
82
- // If same-level multi-volume siblings remain, keep draining them before touching the parent next().
83
- if (descend_pending_multi_volumes()) {
84
- continue;
85
- }
86
- } catch (const EntryFaultError &error) {
87
- dispatch_fault(error.fault());
88
- }
89
- try {
90
- StreamArchive *archive = _head.current_archive();
91
- if (archive) {
92
- // After all volumes are processed, push the parent back to EOF to avoid duplicate next().
93
- archive->skip_to_eof();
94
- }
95
- } catch (const EntryFaultError &error) {
96
- dispatch_fault(error.fault());
97
- }
98
- }
99
- }
100
-
101
- const std::string &ArchiveStackOrchestrator::current_entryname() {
102
- StreamArchive *archive = current_archive();
103
- if (!archive) {
104
- static const std::string empty;
105
- return empty;
106
- }
107
- return archive->current_entryname;
108
- }
109
-
110
- PathHierarchy ArchiveStackOrchestrator::current_entry_hierarchy() { return _head.current_entry_hierarchy(); }
111
-
112
- bool ArchiveStackOrchestrator::synchronize_to_hierarchy(const PathHierarchy &path_hierarchy) {
113
- try {
114
- _head.synchronize_to_hierarchy(path_hierarchy);
115
- return true;
116
- } catch (const EntryFaultError &error) {
117
- dispatch_fault(error.fault());
118
- return false;
119
- }
120
- }
121
-
122
- ssize_t ArchiveStackOrchestrator::read_head(void *buff, size_t len) {
123
- try {
124
- return _head.read(buff, len);
125
- } catch (const EntryFaultError &error) {
126
- dispatch_fault(error.fault());
127
- }
128
-
129
- return -1;
130
- }
131
-
132
- void ArchiveStackOrchestrator::mark_entry_as_multi_volume(const PathHierarchy &entry_path, const std::string &base_name, PathEntry::Parts::Ordering ordering) {
133
- _multi_volume_manager.mark_entry_as_multi_volume(entry_path, base_name, ordering);
134
- }
135
-
136
- bool ArchiveStackOrchestrator::descend_pending_multi_volumes() {
137
- const PathHierarchy current_hierarchy = (depth() == 0) ? PathHierarchy{} : _head.current_entry_hierarchy();
138
- PathHierarchy multi_volume_target;
139
- if (!_multi_volume_manager.pop_multi_volume_group(current_hierarchy, multi_volume_target)) {
140
- return false;
141
- }
142
-
143
- _head.synchronize_to_hierarchy(multi_volume_target);
144
- _head.descend();
145
- return true;
146
- }
147
-
148
- void ArchiveStackOrchestrator::open_root_hierarchy(const PathHierarchy &root_hierarchy) {
149
- _head.synchronize_to_hierarchy(root_hierarchy);
150
- _head.descend();
151
- }
152
-
153
- void ArchiveStackOrchestrator::dispatch_fault(EntryFault fault) {
154
- if (fault.hierarchy.empty()) {
155
- fault.hierarchy = _head.current_entry_hierarchy();
156
- }
157
-
158
- dispatch_registered_fault(fault);
159
- }
160
-
161
- } // namespace archive_r
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2025 archive_r Team
3
+
4
+ #include "archive_stack_orchestrator.h"
5
+ #include "archive_r/entry_fault.h"
6
+ #include "archive_r/path_hierarchy_utils.h"
7
+ #include "system_file_stream.h"
8
+
9
+ #include <algorithm>
10
+ #include <cstddef>
11
+ #include <cstdio>
12
+ #include <exception>
13
+ #include <limits>
14
+ #include <memory>
15
+ #include <stdexcept>
16
+ #include <typeinfo>
17
+ #include <utility>
18
+
19
+ namespace archive_r {
20
+
21
+ ArchiveStackOrchestrator::ArchiveStackOrchestrator(const ArchiveOption &options)
22
+ : _archive_options(options) {
23
+ _head.configure(_archive_options);
24
+ }
25
+
26
+ ArchiveStackOrchestrator::~ArchiveStackOrchestrator() = default;
27
+
28
+ size_t ArchiveStackOrchestrator::depth() const { return _head.depth(); }
29
+
30
+ StreamArchive *ArchiveStackOrchestrator::current_archive() { return _head.current_archive(); }
31
+
32
+ // Drives the traversal state machine:
33
+ // 1. Optionally descend into the current entry when requested.
34
+ // 2. Attempt to advance within the active archive; report faults but keep looping.
35
+ // 3. Drain any pending multi-volume groups before bubbling up to the parent so multipart
36
+ // archives are consumed contiguously.
37
+ // 4. When leaving a multi-volume context, rewind the parent archive by skipping to EOF to
38
+ // avoid re-reading already processed entries.
39
+ bool ArchiveStackOrchestrator::advance(bool descend_request) {
40
+ bool request_descend = descend_request;
41
+
42
+ while (true) {
43
+ if (depth() == 0) {
44
+ return false;
45
+ }
46
+ try {
47
+ if (request_descend) {
48
+ request_descend = false;
49
+ _head.descend();
50
+ }
51
+ } catch (const EntryFaultError &error) {
52
+ dispatch_fault(error.fault());
53
+ continue;
54
+ }
55
+
56
+ try {
57
+ if (_head.next()) {
58
+ return true;
59
+ }
60
+ } catch (const EntryFaultError &error) {
61
+ dispatch_fault(error.fault());
62
+ continue;
63
+ }
64
+
65
+ try {
66
+ // Consume any pending multi-volume siblings so we do not return to the parent mid-series.
67
+ if (descend_pending_multi_volumes()) {
68
+ continue;
69
+ }
70
+ } catch (const EntryFaultError &error) {
71
+ dispatch_fault(error.fault());
72
+ }
73
+
74
+ PathHierarchy prev_ascend_hierarchy = _head.current_entry_hierarchy();
75
+ _head.ascend();
76
+
77
+ if (!pathhierarchy_is_multivolume(prev_ascend_hierarchy)) {
78
+ continue;
79
+ }
80
+
81
+ try {
82
+ // If same-level multi-volume siblings remain, keep draining them before touching the parent next().
83
+ if (descend_pending_multi_volumes()) {
84
+ continue;
85
+ }
86
+ } catch (const EntryFaultError &error) {
87
+ dispatch_fault(error.fault());
88
+ }
89
+ try {
90
+ StreamArchive *archive = _head.current_archive();
91
+ if (archive) {
92
+ // After all volumes are processed, push the parent back to EOF to avoid duplicate next().
93
+ archive->skip_to_eof();
94
+ }
95
+ } catch (const EntryFaultError &error) {
96
+ dispatch_fault(error.fault());
97
+ }
98
+ }
99
+ }
100
+
101
+ const std::string &ArchiveStackOrchestrator::current_entryname() {
102
+ StreamArchive *archive = current_archive();
103
+ if (!archive) {
104
+ static const std::string empty;
105
+ return empty;
106
+ }
107
+ return archive->current_entryname;
108
+ }
109
+
110
+ PathHierarchy ArchiveStackOrchestrator::current_entry_hierarchy() { return _head.current_entry_hierarchy(); }
111
+
112
+ bool ArchiveStackOrchestrator::synchronize_to_hierarchy(const PathHierarchy &path_hierarchy) {
113
+ try {
114
+ _head.synchronize_to_hierarchy(path_hierarchy);
115
+ return true;
116
+ } catch (const EntryFaultError &error) {
117
+ dispatch_fault(error.fault());
118
+ return false;
119
+ }
120
+ }
121
+
122
+ ssize_t ArchiveStackOrchestrator::read_head(void *buff, size_t len) {
123
+ try {
124
+ return _head.read(buff, len);
125
+ } catch (const EntryFaultError &error) {
126
+ dispatch_fault(error.fault());
127
+ }
128
+
129
+ return -1;
130
+ }
131
+
132
+ void ArchiveStackOrchestrator::mark_entry_as_multi_volume(const PathHierarchy &entry_path, const std::string &base_name, PathEntry::Parts::Ordering ordering) {
133
+ _multi_volume_manager.mark_entry_as_multi_volume(entry_path, base_name, ordering);
134
+ }
135
+
136
+ bool ArchiveStackOrchestrator::descend_pending_multi_volumes() {
137
+ const PathHierarchy current_hierarchy = (depth() == 0) ? PathHierarchy{} : _head.current_entry_hierarchy();
138
+ PathHierarchy multi_volume_target;
139
+ if (!_multi_volume_manager.pop_multi_volume_group(current_hierarchy, multi_volume_target)) {
140
+ return false;
141
+ }
142
+
143
+ _head.synchronize_to_hierarchy(multi_volume_target);
144
+ _head.descend();
145
+ return true;
146
+ }
147
+
148
+ void ArchiveStackOrchestrator::open_root_hierarchy(const PathHierarchy &root_hierarchy) {
149
+ _head.synchronize_to_hierarchy(root_hierarchy);
150
+ _head.descend();
151
+ }
152
+
153
+ void ArchiveStackOrchestrator::dispatch_fault(EntryFault fault) {
154
+ if (fault.hierarchy.empty()) {
155
+ fault.hierarchy = _head.current_entry_hierarchy();
156
+ }
157
+
158
+ dispatch_registered_fault(fault);
159
+ }
160
+
161
+ } // namespace archive_r
@@ -1,53 +1,53 @@
1
- // SPDX-License-Identifier: MIT
2
- // Copyright (c) 2025 archive_r Team
3
-
4
- #pragma once
5
-
6
- #include "archive_r/path_hierarchy.h"
7
- #include "archive_r/platform_compat.h"
8
- #include "archive_stack_cursor.h"
9
- #include "archive_type.h"
10
- #include "entry_fault_error.h"
11
- #include "multi_volume_manager.h"
12
- #include <limits>
13
- #include <memory>
14
- #include <string>
15
- #include <unordered_set>
16
-
17
- namespace archive_r {
18
-
19
- class ArchiveStackOrchestrator {
20
- public:
21
- explicit ArchiveStackOrchestrator(const ArchiveOption &options = {});
22
- ArchiveStackOrchestrator(const ArchiveStackOrchestrator &) = delete;
23
- ArchiveStackOrchestrator &operator=(const ArchiveStackOrchestrator &) = delete;
24
-
25
- ~ArchiveStackOrchestrator();
26
-
27
- void open_root_hierarchy(const PathHierarchy &root_hierarchy);
28
-
29
- bool advance(bool descend_request = true);
30
- const std::string &current_entryname();
31
-
32
- size_t depth() const;
33
- PathHierarchy current_entry_hierarchy();
34
- bool synchronize_to_hierarchy(const PathHierarchy &path_hierarchy);
35
-
36
- StreamArchive *current_archive();
37
- ssize_t read_head(void *buff, size_t len);
38
-
39
- const std::unordered_set<std::string> &metadata_keys() const { return _archive_options.metadata_keys; }
40
- const ArchiveOption &options() const { return _archive_options; }
41
-
42
- void mark_entry_as_multi_volume(const PathHierarchy &entry_path, const std::string &base_name, PathEntry::Parts::Ordering ordering = PathEntry::Parts::Ordering::Natural);
43
- bool descend_pending_multi_volumes();
44
-
45
- private:
46
- ArchiveOption _archive_options;
47
- ArchiveStackCursor _head;
48
- MultiVolumeManager _multi_volume_manager;
49
-
50
- void dispatch_fault(EntryFault fault);
51
- };
52
-
53
- } // namespace archive_r
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2025 archive_r Team
3
+
4
+ #pragma once
5
+
6
+ #include "archive_r/path_hierarchy.h"
7
+ #include "archive_r/platform_compat.h"
8
+ #include "archive_stack_cursor.h"
9
+ #include "archive_type.h"
10
+ #include "entry_fault_error.h"
11
+ #include "multi_volume_manager.h"
12
+ #include <limits>
13
+ #include <memory>
14
+ #include <string>
15
+ #include <unordered_set>
16
+
17
+ namespace archive_r {
18
+
19
+ class ArchiveStackOrchestrator {
20
+ public:
21
+ explicit ArchiveStackOrchestrator(const ArchiveOption &options = {});
22
+ ArchiveStackOrchestrator(const ArchiveStackOrchestrator &) = delete;
23
+ ArchiveStackOrchestrator &operator=(const ArchiveStackOrchestrator &) = delete;
24
+
25
+ ~ArchiveStackOrchestrator();
26
+
27
+ void open_root_hierarchy(const PathHierarchy &root_hierarchy);
28
+
29
+ bool advance(bool descend_request = true);
30
+ const std::string &current_entryname();
31
+
32
+ size_t depth() const;
33
+ PathHierarchy current_entry_hierarchy();
34
+ bool synchronize_to_hierarchy(const PathHierarchy &path_hierarchy);
35
+
36
+ StreamArchive *current_archive();
37
+ ssize_t read_head(void *buff, size_t len);
38
+
39
+ const std::unordered_set<std::string> &metadata_keys() const { return _archive_options.metadata_keys; }
40
+ const ArchiveOption &options() const { return _archive_options; }
41
+
42
+ void mark_entry_as_multi_volume(const PathHierarchy &entry_path, const std::string &base_name, PathEntry::Parts::Ordering ordering = PathEntry::Parts::Ordering::Natural);
43
+ bool descend_pending_multi_volumes();
44
+
45
+ private:
46
+ ArchiveOption _archive_options;
47
+ ArchiveStackCursor _head;
48
+ MultiVolumeManager _multi_volume_manager;
49
+
50
+ void dispatch_fault(EntryFault fault);
51
+ };
52
+
53
+ } // namespace archive_r