archive_r_ruby 0.1.21 → 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 +3 -6
@@ -1,180 +1,180 @@
1
- // SPDX-License-Identifier: MIT
2
- // Copyright (c) 2025 archive_r Team
3
-
4
- #pragma once
5
-
6
- #include <cstdint>
7
- #include <filesystem>
8
- #include <memory>
9
- #include <string>
10
- #include <vector>
11
-
12
- #include "archive_r/entry_fault.h"
13
- #include "archive_r/entry_metadata.h"
14
- #include "archive_r/path_hierarchy.h"
15
- #include "archive_r/platform_compat.h"
16
-
17
- namespace archive_r {
18
-
19
- class ArchiveStackOrchestrator;
20
-
21
- struct MultiVolumeGroupOptions {
22
- PathEntry::Parts::Ordering ordering = PathEntry::Parts::Ordering::Natural;
23
- };
24
-
25
- /**
26
- * @brief Represents a single entry in an archive traversal
27
- *
28
- * Entry objects encapsulate all information about an archive entry including:
29
- * - Path information (path, path hierarchy)
30
- * - Metadata (size, type, timestamps)
31
- * - Content access (read operations)
32
- * - Multi-volume archive grouping support
33
- *
34
- * \par Lifetime and Copying
35
- * - An Entry& obtained while iterating a Traverser is typically valid until the
36
- * iterator advances.
37
- * - Entry is copyable. Copies retain metadata (name/path/metadata/etc), but do not
38
- * retain traverser-managed traversal control state. Calling set_descent() or
39
- * set_multi_volume_group() on such copies will report a fault and has no effect.
40
- * Prefer calling these control methods on the Entry& inside the iteration loop,
41
- * before advancing.
42
- *
43
- * \par Reading
44
- * - read() returns >0 for bytes read, 0 for EOF, -1 for error.
45
- * - On error, read() dispatches an EntryFault via the registered fault callback
46
- * (if any).
47
- * - After any successful read() (including EOF), descent is disabled until
48
- * explicitly re-enabled via set_descent(true).
49
- */
50
- class Entry {
51
- public:
52
- /**
53
- * @brief Get the entry name (last element of the path hierarchy)
54
- * @return Entry name relative to its containing archive (e.g., "dir/subdir/file.txt" when the
55
- * hierarchy is {"outer/archive.zip", "dir/subdir/file.txt"})
56
- */
57
- std::string name() const;
58
-
59
- /**
60
- * @brief Get the entry path as a string
61
- * @return Joined path including outer archives (e.g., "outer/archive.zip/dir/subdir/file.txt"
62
- * when the hierarchy is {"outer/archive.zip", "dir/subdir/file.txt"})
63
- */
64
- std::string path() const;
65
-
66
- /**
67
- * @brief Get the entry path as a hierarchy of components
68
- * @return Vector describing each descent step (e.g., {"outer/archive.zip",
69
- * "dir/subdir/file.txt"})
70
- */
71
- const PathHierarchy &path_hierarchy() const;
72
-
73
- /**
74
- * @brief Check if entry is a directory
75
- * @return true if entry represents a directory
76
- */
77
- bool is_directory() const;
78
-
79
- /**
80
- * @brief Check if entry is a regular file
81
- * @return true if entry represents a regular file
82
- */
83
- bool is_file() const;
84
-
85
- /**
86
- * @brief Get the uncompressed size of the entry
87
- * @return Size in bytes, or 0 if unknown
88
- */
89
- uint64_t size() const;
90
-
91
- /**
92
- * @brief Get the archive nesting depth
93
- * @return 0 for top-level archive, 1 for nested archive, etc.
94
- */
95
- size_t depth() const;
96
-
97
- /**
98
- * @brief Read data from the entry
99
- *
100
- * Each call uses an internal ArchiveStackOrchestrator so reads remain valid even
101
- * if the owning iterator advances.
102
- *
103
- * @param buffer Buffer to read data into
104
- * @param length Maximum number of bytes to read
105
- * @return Number of bytes read, 0 on EOF, -1 on error
106
- */
107
- ssize_t read(void *buffer, size_t length);
108
-
109
- /**
110
- * @brief Enable or disable automatic descent into this entry
111
- * @param enabled true to descend (default), false to keep traversal at current level
112
- *
113
- * This control is only available for entries that are managed by a Traverser.
114
- * Calling this on an Entry that is not traverser-managed reports a fault.
115
- */
116
- void set_descent(bool enabled);
117
-
118
- /**
119
- * @brief Check if automatic descent is currently enabled
120
- */
121
- bool descent_enabled() const;
122
-
123
- /**
124
- * @brief Register this entry as part of a multi-volume (split) archive
125
- * @param base_name Base name without the volume suffix (e.g., "archive.tar.gz")
126
- * @param options Optional configuration (e.g., preserve Given ordering)
127
- *
128
- * Register each entry that belongs to the same multi-volume group so that
129
- * once traversal of the parent archive finishes, the parts are combined
130
- * automatically. The traverser will then descend into the combined archive
131
- * and continue processing its contents.
132
- *
133
- * Example:
134
- * @code
135
- * for (Entry& entry : traverser) {
136
- * if (entry.path().find(".part") != std::string::npos) {
137
- * std::string base = extract_base_name(entry.path());
138
- * entry.set_multi_volume_group(base);
139
- * }
140
- * }
141
- * @endcode
142
- *
143
- * This control is only available for entries that are managed by a Traverser.
144
- * Calling this on an Entry that is not traverser-managed reports a fault.
145
- */
146
- void set_multi_volume_group(const std::string &base_name, const MultiVolumeGroupOptions &options = {});
147
-
148
- /**
149
- * @brief Get metadata captured for this entry
150
- * @return Immutable metadata map keyed by libarchive field names
151
- */
152
- const EntryMetadataMap &metadata() const;
153
-
154
- /**
155
- * @brief Look up a metadata value by key
156
- * @param key Metadata key (e.g., "uid", "mtime")
157
- * @return Pointer to the stored value, or nullptr if not present
158
- */
159
- const EntryMetadataValue *find_metadata(const std::string &key) const;
160
-
161
- static std::unique_ptr<Entry> create(PathHierarchy hierarchy, std::shared_ptr<ArchiveStackOrchestrator> data_source_orchestrator, bool default_descent);
162
-
163
- // Copy/move operations
164
- Entry(const Entry &);
165
- Entry &operator=(const Entry &);
166
- Entry(Entry &&) noexcept;
167
- Entry &operator=(Entry &&) noexcept;
168
-
169
- ~Entry();
170
-
171
- private:
172
- class Impl;
173
- std::unique_ptr<Impl> _impl;
174
-
175
- // Private constructor - only friends can create Entry objects
176
- explicit Entry(Impl *impl);
177
- Entry(const PathHierarchy &hierarchy, std::shared_ptr<ArchiveStackOrchestrator> data_source_orchestrator, bool default_descent);
178
- };
179
-
180
- } // namespace archive_r
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2025 archive_r Team
3
+
4
+ #pragma once
5
+
6
+ #include <cstdint>
7
+ #include <filesystem>
8
+ #include <memory>
9
+ #include <string>
10
+ #include <vector>
11
+
12
+ #include "archive_r/entry_fault.h"
13
+ #include "archive_r/entry_metadata.h"
14
+ #include "archive_r/path_hierarchy.h"
15
+ #include "archive_r/platform_compat.h"
16
+
17
+ namespace archive_r {
18
+
19
+ class ArchiveStackOrchestrator;
20
+
21
+ struct MultiVolumeGroupOptions {
22
+ PathEntry::Parts::Ordering ordering = PathEntry::Parts::Ordering::Natural;
23
+ };
24
+
25
+ /**
26
+ * @brief Represents a single entry in an archive traversal
27
+ *
28
+ * Entry objects encapsulate all information about an archive entry including:
29
+ * - Path information (path, path hierarchy)
30
+ * - Metadata (size, type, timestamps)
31
+ * - Content access (read operations)
32
+ * - Multi-volume archive grouping support
33
+ *
34
+ * \par Lifetime and Copying
35
+ * - An Entry& obtained while iterating a Traverser is typically valid until the
36
+ * iterator advances.
37
+ * - Entry is copyable. Copies retain metadata (name/path/metadata/etc), but do not
38
+ * retain traverser-managed traversal control state. Calling set_descent() or
39
+ * set_multi_volume_group() on such copies will report a fault and has no effect.
40
+ * Prefer calling these control methods on the Entry& inside the iteration loop,
41
+ * before advancing.
42
+ *
43
+ * \par Reading
44
+ * - read() returns >0 for bytes read, 0 for EOF, -1 for error.
45
+ * - On error, read() dispatches an EntryFault via the registered fault callback
46
+ * (if any).
47
+ * - After any successful read() (including EOF), descent is disabled until
48
+ * explicitly re-enabled via set_descent(true).
49
+ */
50
+ class Entry {
51
+ public:
52
+ /**
53
+ * @brief Get the entry name (last element of the path hierarchy)
54
+ * @return Entry name relative to its containing archive (e.g., "dir/subdir/file.txt" when the
55
+ * hierarchy is {"outer/archive.zip", "dir/subdir/file.txt"})
56
+ */
57
+ std::string name() const;
58
+
59
+ /**
60
+ * @brief Get the entry path as a string
61
+ * @return Joined path including outer archives (e.g., "outer/archive.zip/dir/subdir/file.txt"
62
+ * when the hierarchy is {"outer/archive.zip", "dir/subdir/file.txt"})
63
+ */
64
+ std::string path() const;
65
+
66
+ /**
67
+ * @brief Get the entry path as a hierarchy of components
68
+ * @return Vector describing each descent step (e.g., {"outer/archive.zip",
69
+ * "dir/subdir/file.txt"})
70
+ */
71
+ const PathHierarchy &path_hierarchy() const;
72
+
73
+ /**
74
+ * @brief Check if entry is a directory
75
+ * @return true if entry represents a directory
76
+ */
77
+ bool is_directory() const;
78
+
79
+ /**
80
+ * @brief Check if entry is a regular file
81
+ * @return true if entry represents a regular file
82
+ */
83
+ bool is_file() const;
84
+
85
+ /**
86
+ * @brief Get the uncompressed size of the entry
87
+ * @return Size in bytes, or 0 if unknown
88
+ */
89
+ uint64_t size() const;
90
+
91
+ /**
92
+ * @brief Get the archive nesting depth
93
+ * @return 0 for top-level archive, 1 for nested archive, etc.
94
+ */
95
+ size_t depth() const;
96
+
97
+ /**
98
+ * @brief Read data from the entry
99
+ *
100
+ * Each call uses an internal ArchiveStackOrchestrator so reads remain valid even
101
+ * if the owning iterator advances.
102
+ *
103
+ * @param buffer Buffer to read data into
104
+ * @param length Maximum number of bytes to read
105
+ * @return Number of bytes read, 0 on EOF, -1 on error
106
+ */
107
+ ssize_t read(void *buffer, size_t length);
108
+
109
+ /**
110
+ * @brief Enable or disable automatic descent into this entry
111
+ * @param enabled true to descend (default), false to keep traversal at current level
112
+ *
113
+ * This control is only available for entries that are managed by a Traverser.
114
+ * Calling this on an Entry that is not traverser-managed reports a fault.
115
+ */
116
+ void set_descent(bool enabled);
117
+
118
+ /**
119
+ * @brief Check if automatic descent is currently enabled
120
+ */
121
+ bool descent_enabled() const;
122
+
123
+ /**
124
+ * @brief Register this entry as part of a multi-volume (split) archive
125
+ * @param base_name Base name without the volume suffix (e.g., "archive.tar.gz")
126
+ * @param options Optional configuration (e.g., preserve Given ordering)
127
+ *
128
+ * Register each entry that belongs to the same multi-volume group so that
129
+ * once traversal of the parent archive finishes, the parts are combined
130
+ * automatically. The traverser will then descend into the combined archive
131
+ * and continue processing its contents.
132
+ *
133
+ * Example:
134
+ * @code
135
+ * for (Entry& entry : traverser) {
136
+ * if (entry.path().find(".part") != std::string::npos) {
137
+ * std::string base = extract_base_name(entry.path());
138
+ * entry.set_multi_volume_group(base);
139
+ * }
140
+ * }
141
+ * @endcode
142
+ *
143
+ * This control is only available for entries that are managed by a Traverser.
144
+ * Calling this on an Entry that is not traverser-managed reports a fault.
145
+ */
146
+ void set_multi_volume_group(const std::string &base_name, const MultiVolumeGroupOptions &options = {});
147
+
148
+ /**
149
+ * @brief Get metadata captured for this entry
150
+ * @return Immutable metadata map keyed by libarchive field names
151
+ */
152
+ const EntryMetadataMap &metadata() const;
153
+
154
+ /**
155
+ * @brief Look up a metadata value by key
156
+ * @param key Metadata key (e.g., "uid", "mtime")
157
+ * @return Pointer to the stored value, or nullptr if not present
158
+ */
159
+ const EntryMetadataValue *find_metadata(const std::string &key) const;
160
+
161
+ static std::unique_ptr<Entry> create(PathHierarchy hierarchy, std::shared_ptr<ArchiveStackOrchestrator> data_source_orchestrator, bool default_descent);
162
+
163
+ // Copy/move operations
164
+ Entry(const Entry &);
165
+ Entry &operator=(const Entry &);
166
+ Entry(Entry &&) noexcept;
167
+ Entry &operator=(Entry &&) noexcept;
168
+
169
+ ~Entry();
170
+
171
+ private:
172
+ class Impl;
173
+ std::unique_ptr<Impl> _impl;
174
+
175
+ // Private constructor - only friends can create Entry objects
176
+ explicit Entry(Impl *impl);
177
+ Entry(const PathHierarchy &hierarchy, std::shared_ptr<ArchiveStackOrchestrator> data_source_orchestrator, bool default_descent);
178
+ };
179
+
180
+ } // namespace archive_r
@@ -1,34 +1,34 @@
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
-
8
- #include <functional>
9
- #include <string>
10
-
11
- namespace archive_r {
12
-
13
- /** Describes a recoverable failure encountered while visiting an entry. */
14
- struct EntryFault {
15
- PathHierarchy hierarchy; ///< Path hierarchy where the fault occurred
16
- std::string message; ///< Human readable description
17
- int errno_value = 0; ///< Optional errno captured from the failing API
18
- };
19
-
20
- /** Callback signature used to surface EntryFault notifications. */
21
- using FaultCallback = std::function<void(const EntryFault &)>;
22
-
23
- /**
24
- * @brief Register a global callback to receive EntryFault notifications.
25
- * Pass an empty std::function to clear the callback.
26
- */
27
- void register_fault_callback(FaultCallback callback);
28
-
29
- /**
30
- * @brief Dispatch a fault through the globally registered callback, if any.
31
- */
32
- void dispatch_registered_fault(const EntryFault &fault);
33
-
34
- } // 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
+
8
+ #include <functional>
9
+ #include <string>
10
+
11
+ namespace archive_r {
12
+
13
+ /** Describes a recoverable failure encountered while visiting an entry. */
14
+ struct EntryFault {
15
+ PathHierarchy hierarchy; ///< Path hierarchy where the fault occurred
16
+ std::string message; ///< Human readable description
17
+ int errno_value = 0; ///< Optional errno captured from the failing API
18
+ };
19
+
20
+ /** Callback signature used to surface EntryFault notifications. */
21
+ using FaultCallback = std::function<void(const EntryFault &)>;
22
+
23
+ /**
24
+ * @brief Register a global callback to receive EntryFault notifications.
25
+ * Pass an empty std::function to clear the callback.
26
+ */
27
+ void register_fault_callback(FaultCallback callback);
28
+
29
+ /**
30
+ * @brief Dispatch a fault through the globally registered callback, if any.
31
+ */
32
+ void dispatch_registered_fault(const EntryFault &fault);
33
+
34
+ } // namespace archive_r
@@ -1,56 +1,56 @@
1
- // SPDX-License-Identifier: MIT
2
- // Copyright (c) 2025 archive_r Team
3
-
4
- #pragma once
5
-
6
- #include <cstdint>
7
- #include <string>
8
- #include <unordered_map>
9
- #include <variant>
10
- #include <vector>
11
-
12
- namespace archive_r {
13
-
14
- /** POSIX-style timestamp with sub-second precision. */
15
- struct EntryMetadataTime {
16
- int64_t seconds;
17
- int32_t nanoseconds;
18
- };
19
-
20
- /** Sparse file chunk (offset + stored length). */
21
- struct EntryMetadataSparseChunk {
22
- int64_t offset;
23
- int64_t length;
24
- };
25
-
26
- /** Extended attribute key/value pair. */
27
- struct EntryMetadataXattr {
28
- std::string name;
29
- std::vector<uint8_t> value;
30
- };
31
-
32
- /** Generic digest (algorithm + raw bytes). */
33
- struct EntryMetadataDigest {
34
- std::string algorithm;
35
- std::vector<uint8_t> value;
36
- };
37
-
38
- /** Device identifiers for special files. */
39
- struct EntryMetadataDeviceNumbers {
40
- uint64_t major;
41
- uint64_t minor;
42
- };
43
-
44
- /** BSD-style file flags (bits to set/clear). */
45
- struct EntryMetadataFileFlags {
46
- uint64_t set;
47
- uint64_t clear;
48
- };
49
-
50
- using EntryMetadataValue = std::variant<std::monostate, bool, int64_t, uint64_t, std::string, std::vector<uint8_t>, EntryMetadataTime, EntryMetadataDeviceNumbers, EntryMetadataFileFlags,
51
- std::vector<EntryMetadataXattr>, std::vector<EntryMetadataSparseChunk>, std::vector<EntryMetadataDigest>>;
52
-
53
- /** Unordered map storing metadata captured during traversal. */
54
- using EntryMetadataMap = std::unordered_map<std::string, EntryMetadataValue>;
55
-
56
- } // namespace archive_r
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2025 archive_r Team
3
+
4
+ #pragma once
5
+
6
+ #include <cstdint>
7
+ #include <string>
8
+ #include <unordered_map>
9
+ #include <variant>
10
+ #include <vector>
11
+
12
+ namespace archive_r {
13
+
14
+ /** POSIX-style timestamp with sub-second precision. */
15
+ struct EntryMetadataTime {
16
+ int64_t seconds;
17
+ int32_t nanoseconds;
18
+ };
19
+
20
+ /** Sparse file chunk (offset + stored length). */
21
+ struct EntryMetadataSparseChunk {
22
+ int64_t offset;
23
+ int64_t length;
24
+ };
25
+
26
+ /** Extended attribute key/value pair. */
27
+ struct EntryMetadataXattr {
28
+ std::string name;
29
+ std::vector<uint8_t> value;
30
+ };
31
+
32
+ /** Generic digest (algorithm + raw bytes). */
33
+ struct EntryMetadataDigest {
34
+ std::string algorithm;
35
+ std::vector<uint8_t> value;
36
+ };
37
+
38
+ /** Device identifiers for special files. */
39
+ struct EntryMetadataDeviceNumbers {
40
+ uint64_t major;
41
+ uint64_t minor;
42
+ };
43
+
44
+ /** BSD-style file flags (bits to set/clear). */
45
+ struct EntryMetadataFileFlags {
46
+ uint64_t set;
47
+ uint64_t clear;
48
+ };
49
+
50
+ using EntryMetadataValue = std::variant<std::monostate, bool, int64_t, uint64_t, std::string, std::vector<uint8_t>, EntryMetadataTime, EntryMetadataDeviceNumbers, EntryMetadataFileFlags,
51
+ std::vector<EntryMetadataXattr>, std::vector<EntryMetadataSparseChunk>, std::vector<EntryMetadataDigest>>;
52
+
53
+ /** Unordered map storing metadata captured during traversal. */
54
+ using EntryMetadataMap = std::unordered_map<std::string, EntryMetadataValue>;
55
+
56
+ } // namespace archive_r
@@ -1,46 +1,46 @@
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/path_hierarchy.h"
8
-
9
- #include <cstddef>
10
- #include <cstdint>
11
- #include <memory>
12
-
13
- namespace archive_r {
14
-
15
- class MultiVolumeStreamBase : public IDataStream {
16
- public:
17
- ~MultiVolumeStreamBase() override;
18
-
19
- ssize_t read(void *buffer, size_t size) override;
20
- void rewind() override;
21
- bool at_end() const override;
22
- int64_t seek(int64_t offset, int whence) override;
23
- int64_t tell() const override;
24
- bool can_seek() const override { return _supports_seek; }
25
- PathHierarchy source_hierarchy() const override { return _logical_path; }
26
-
27
- protected:
28
- MultiVolumeStreamBase(PathHierarchy logical_path, bool supports_seek);
29
-
30
- virtual void open_single_part(const PathHierarchy &single_part) = 0;
31
- virtual void close_single_part() = 0;
32
- virtual ssize_t read_from_single_part(void *buffer, size_t size) = 0;
33
- virtual int64_t seek_within_single_part(int64_t offset, int whence);
34
- virtual int64_t size_of_single_part(const PathHierarchy &single_part);
35
-
36
- PathHierarchy _logical_path;
37
- void deactivate_active_part();
38
-
39
- private:
40
- friend struct Impl;
41
- struct Impl;
42
- std::unique_ptr<Impl> _impl;
43
- const bool _supports_seek;
44
- };
45
-
46
- } // 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/path_hierarchy.h"
8
+
9
+ #include <cstddef>
10
+ #include <cstdint>
11
+ #include <memory>
12
+
13
+ namespace archive_r {
14
+
15
+ class MultiVolumeStreamBase : public IDataStream {
16
+ public:
17
+ ~MultiVolumeStreamBase() override;
18
+
19
+ ssize_t read(void *buffer, size_t size) override;
20
+ void rewind() override;
21
+ bool at_end() const override;
22
+ int64_t seek(int64_t offset, int whence) override;
23
+ int64_t tell() const override;
24
+ bool can_seek() const override { return _supports_seek; }
25
+ PathHierarchy source_hierarchy() const override { return _logical_path; }
26
+
27
+ protected:
28
+ MultiVolumeStreamBase(PathHierarchy logical_path, bool supports_seek);
29
+
30
+ virtual void open_single_part(const PathHierarchy &single_part) = 0;
31
+ virtual void close_single_part() = 0;
32
+ virtual ssize_t read_from_single_part(void *buffer, size_t size) = 0;
33
+ virtual int64_t seek_within_single_part(int64_t offset, int whence);
34
+ virtual int64_t size_of_single_part(const PathHierarchy &single_part);
35
+
36
+ PathHierarchy _logical_path;
37
+ void deactivate_active_part();
38
+
39
+ private:
40
+ friend struct Impl;
41
+ struct Impl;
42
+ std::unique_ptr<Impl> _impl;
43
+ const bool _supports_seek;
44
+ };
45
+
46
+ } // namespace archive_r