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,166 +1,166 @@
|
|
|
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 <sys/types.h>
|
|
11
|
-
#include <vector>
|
|
12
|
-
|
|
13
|
-
#ifdef _MSC_VER
|
|
14
|
-
#include <BaseTsd.h>
|
|
15
|
-
typedef SSIZE_T ssize_t;
|
|
16
|
-
#endif
|
|
17
|
-
|
|
18
|
-
#include "archive_r/entry_fault.h"
|
|
19
|
-
#include "archive_r/entry_metadata.h"
|
|
20
|
-
#include "archive_r/path_hierarchy.h"
|
|
21
|
-
|
|
22
|
-
namespace archive_r {
|
|
23
|
-
|
|
24
|
-
class ArchiveStackOrchestrator;
|
|
25
|
-
|
|
26
|
-
struct MultiVolumeGroupOptions {
|
|
27
|
-
PathEntry::Parts::Ordering ordering = PathEntry::Parts::Ordering::Natural;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @brief Represents a single entry in an archive traversal
|
|
32
|
-
*
|
|
33
|
-
* Entry objects encapsulate all information about an archive entry including:
|
|
34
|
-
* - Path information (path, path hierarchy)
|
|
35
|
-
* - Metadata (size, type, timestamps)
|
|
36
|
-
* - Content access (read operations)
|
|
37
|
-
* - Multi-volume archive grouping support
|
|
38
|
-
*
|
|
39
|
-
* Entry objects are typically obtained from ArchiveTraverser::Iterator and
|
|
40
|
-
* remain valid until the iterator advances.
|
|
41
|
-
*/
|
|
42
|
-
class Entry {
|
|
43
|
-
public:
|
|
44
|
-
/**
|
|
45
|
-
* @brief Get the entry name (last element of the path hierarchy)
|
|
46
|
-
* @return Entry name relative to its containing archive (e.g., "dir/subdir/file.txt" when the
|
|
47
|
-
* hierarchy is {"outer/archive.zip", "dir/subdir/file.txt"})
|
|
48
|
-
*/
|
|
49
|
-
std::string name() const;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @brief Get the entry path as a string
|
|
53
|
-
* @return Joined path including outer archives (e.g., "outer/archive.zip/dir/subdir/file.txt"
|
|
54
|
-
* when the hierarchy is {"outer/archive.zip", "dir/subdir/file.txt"})
|
|
55
|
-
*/
|
|
56
|
-
std::string path() const;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* @brief Get the entry path as a hierarchy of components
|
|
60
|
-
* @return Vector describing each descent step (e.g., {"outer/archive.zip",
|
|
61
|
-
* "dir/subdir/file.txt"})
|
|
62
|
-
*/
|
|
63
|
-
const PathHierarchy &path_hierarchy() const;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @brief Check if entry is a directory
|
|
67
|
-
* @return true if entry represents a directory
|
|
68
|
-
*/
|
|
69
|
-
bool is_directory() const;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* @brief Check if entry is a regular file
|
|
73
|
-
* @return true if entry represents a regular file
|
|
74
|
-
*/
|
|
75
|
-
bool is_file() const;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @brief Get the uncompressed size of the entry
|
|
79
|
-
* @return Size in bytes, or 0 if unknown
|
|
80
|
-
*/
|
|
81
|
-
uint64_t size() const;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* @brief Get the archive nesting depth
|
|
85
|
-
* @return 0 for top-level archive, 1 for nested archive, etc.
|
|
86
|
-
*/
|
|
87
|
-
size_t depth() const;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* @brief Read data from the entry
|
|
91
|
-
*
|
|
92
|
-
* Each call uses an internal ArchiveStackOrchestrator so reads remain valid even
|
|
93
|
-
* if the owning iterator advances or other traversal work continues in parallel.
|
|
94
|
-
*
|
|
95
|
-
* @param buffer Buffer to read data into
|
|
96
|
-
* @param length Maximum number of bytes to read
|
|
97
|
-
* @return Number of bytes read, 0 on EOF, -1 on error
|
|
98
|
-
*/
|
|
99
|
-
ssize_t read(void *buffer, size_t length);
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* @brief Enable or disable automatic descent into this entry
|
|
103
|
-
* @param enabled true to descend (default), false to keep traversal at current level
|
|
104
|
-
*/
|
|
105
|
-
void set_descent(bool enabled);
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* @brief Check if automatic descent is currently enabled
|
|
109
|
-
*/
|
|
110
|
-
bool descent_enabled() const;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* @brief Register this entry as part of a multi-volume (split) archive
|
|
114
|
-
* @param base_name Base name without the volume suffix (e.g., "archive.tar.gz")
|
|
115
|
-
* @param options Optional configuration (e.g., preserve Given ordering)
|
|
116
|
-
*
|
|
117
|
-
* Register each entry that belongs to the same multi-volume group so that
|
|
118
|
-
* once traversal of the parent archive finishes, the parts are combined
|
|
119
|
-
* automatically. The traverser will then descend into the combined archive
|
|
120
|
-
* and continue processing its contents.
|
|
121
|
-
*
|
|
122
|
-
* Example:
|
|
123
|
-
* @code
|
|
124
|
-
* for (Entry& entry : traverser) {
|
|
125
|
-
* if (entry.path().find(".part") != std::string::npos) {
|
|
126
|
-
* std::string base = extract_base_name(entry.path());
|
|
127
|
-
* entry.set_multi_volume_group(base);
|
|
128
|
-
* }
|
|
129
|
-
* }
|
|
130
|
-
* @endcode
|
|
131
|
-
*/
|
|
132
|
-
void set_multi_volume_group(const std::string &base_name, const MultiVolumeGroupOptions &options = {});
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* @brief Get metadata captured for this entry
|
|
136
|
-
* @return Immutable metadata map keyed by libarchive field names
|
|
137
|
-
*/
|
|
138
|
-
const EntryMetadataMap &metadata() const;
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* @brief Look up a metadata value by key
|
|
142
|
-
* @param key Metadata key (e.g., "uid", "mtime")
|
|
143
|
-
* @return Pointer to the stored value, or nullptr if not present
|
|
144
|
-
*/
|
|
145
|
-
const EntryMetadataValue *find_metadata(const std::string &key) const;
|
|
146
|
-
|
|
147
|
-
static std::unique_ptr<Entry> create(PathHierarchy hierarchy, std::shared_ptr<ArchiveStackOrchestrator> data_source_orchestrator, bool default_descent);
|
|
148
|
-
|
|
149
|
-
// Copy/move operations
|
|
150
|
-
Entry(const Entry &);
|
|
151
|
-
Entry &operator=(const Entry &);
|
|
152
|
-
Entry(Entry &&) noexcept;
|
|
153
|
-
Entry &operator=(Entry &&) noexcept;
|
|
154
|
-
|
|
155
|
-
~Entry();
|
|
156
|
-
|
|
157
|
-
private:
|
|
158
|
-
class Impl;
|
|
159
|
-
std::unique_ptr<Impl> _impl;
|
|
160
|
-
|
|
161
|
-
// Private constructor - only friends can create Entry objects
|
|
162
|
-
explicit Entry(Impl *impl);
|
|
163
|
-
Entry(const PathHierarchy &hierarchy, std::shared_ptr<ArchiveStackOrchestrator> data_source_orchestrator, bool default_descent);
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
} // 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 <sys/types.h>
|
|
11
|
+
#include <vector>
|
|
12
|
+
|
|
13
|
+
#ifdef _MSC_VER
|
|
14
|
+
#include <BaseTsd.h>
|
|
15
|
+
typedef SSIZE_T ssize_t;
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
#include "archive_r/entry_fault.h"
|
|
19
|
+
#include "archive_r/entry_metadata.h"
|
|
20
|
+
#include "archive_r/path_hierarchy.h"
|
|
21
|
+
|
|
22
|
+
namespace archive_r {
|
|
23
|
+
|
|
24
|
+
class ArchiveStackOrchestrator;
|
|
25
|
+
|
|
26
|
+
struct MultiVolumeGroupOptions {
|
|
27
|
+
PathEntry::Parts::Ordering ordering = PathEntry::Parts::Ordering::Natural;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @brief Represents a single entry in an archive traversal
|
|
32
|
+
*
|
|
33
|
+
* Entry objects encapsulate all information about an archive entry including:
|
|
34
|
+
* - Path information (path, path hierarchy)
|
|
35
|
+
* - Metadata (size, type, timestamps)
|
|
36
|
+
* - Content access (read operations)
|
|
37
|
+
* - Multi-volume archive grouping support
|
|
38
|
+
*
|
|
39
|
+
* Entry objects are typically obtained from ArchiveTraverser::Iterator and
|
|
40
|
+
* remain valid until the iterator advances.
|
|
41
|
+
*/
|
|
42
|
+
class Entry {
|
|
43
|
+
public:
|
|
44
|
+
/**
|
|
45
|
+
* @brief Get the entry name (last element of the path hierarchy)
|
|
46
|
+
* @return Entry name relative to its containing archive (e.g., "dir/subdir/file.txt" when the
|
|
47
|
+
* hierarchy is {"outer/archive.zip", "dir/subdir/file.txt"})
|
|
48
|
+
*/
|
|
49
|
+
std::string name() const;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @brief Get the entry path as a string
|
|
53
|
+
* @return Joined path including outer archives (e.g., "outer/archive.zip/dir/subdir/file.txt"
|
|
54
|
+
* when the hierarchy is {"outer/archive.zip", "dir/subdir/file.txt"})
|
|
55
|
+
*/
|
|
56
|
+
std::string path() const;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @brief Get the entry path as a hierarchy of components
|
|
60
|
+
* @return Vector describing each descent step (e.g., {"outer/archive.zip",
|
|
61
|
+
* "dir/subdir/file.txt"})
|
|
62
|
+
*/
|
|
63
|
+
const PathHierarchy &path_hierarchy() const;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @brief Check if entry is a directory
|
|
67
|
+
* @return true if entry represents a directory
|
|
68
|
+
*/
|
|
69
|
+
bool is_directory() const;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @brief Check if entry is a regular file
|
|
73
|
+
* @return true if entry represents a regular file
|
|
74
|
+
*/
|
|
75
|
+
bool is_file() const;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @brief Get the uncompressed size of the entry
|
|
79
|
+
* @return Size in bytes, or 0 if unknown
|
|
80
|
+
*/
|
|
81
|
+
uint64_t size() const;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @brief Get the archive nesting depth
|
|
85
|
+
* @return 0 for top-level archive, 1 for nested archive, etc.
|
|
86
|
+
*/
|
|
87
|
+
size_t depth() const;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @brief Read data from the entry
|
|
91
|
+
*
|
|
92
|
+
* Each call uses an internal ArchiveStackOrchestrator so reads remain valid even
|
|
93
|
+
* if the owning iterator advances or other traversal work continues in parallel.
|
|
94
|
+
*
|
|
95
|
+
* @param buffer Buffer to read data into
|
|
96
|
+
* @param length Maximum number of bytes to read
|
|
97
|
+
* @return Number of bytes read, 0 on EOF, -1 on error
|
|
98
|
+
*/
|
|
99
|
+
ssize_t read(void *buffer, size_t length);
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @brief Enable or disable automatic descent into this entry
|
|
103
|
+
* @param enabled true to descend (default), false to keep traversal at current level
|
|
104
|
+
*/
|
|
105
|
+
void set_descent(bool enabled);
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @brief Check if automatic descent is currently enabled
|
|
109
|
+
*/
|
|
110
|
+
bool descent_enabled() const;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @brief Register this entry as part of a multi-volume (split) archive
|
|
114
|
+
* @param base_name Base name without the volume suffix (e.g., "archive.tar.gz")
|
|
115
|
+
* @param options Optional configuration (e.g., preserve Given ordering)
|
|
116
|
+
*
|
|
117
|
+
* Register each entry that belongs to the same multi-volume group so that
|
|
118
|
+
* once traversal of the parent archive finishes, the parts are combined
|
|
119
|
+
* automatically. The traverser will then descend into the combined archive
|
|
120
|
+
* and continue processing its contents.
|
|
121
|
+
*
|
|
122
|
+
* Example:
|
|
123
|
+
* @code
|
|
124
|
+
* for (Entry& entry : traverser) {
|
|
125
|
+
* if (entry.path().find(".part") != std::string::npos) {
|
|
126
|
+
* std::string base = extract_base_name(entry.path());
|
|
127
|
+
* entry.set_multi_volume_group(base);
|
|
128
|
+
* }
|
|
129
|
+
* }
|
|
130
|
+
* @endcode
|
|
131
|
+
*/
|
|
132
|
+
void set_multi_volume_group(const std::string &base_name, const MultiVolumeGroupOptions &options = {});
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @brief Get metadata captured for this entry
|
|
136
|
+
* @return Immutable metadata map keyed by libarchive field names
|
|
137
|
+
*/
|
|
138
|
+
const EntryMetadataMap &metadata() const;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @brief Look up a metadata value by key
|
|
142
|
+
* @param key Metadata key (e.g., "uid", "mtime")
|
|
143
|
+
* @return Pointer to the stored value, or nullptr if not present
|
|
144
|
+
*/
|
|
145
|
+
const EntryMetadataValue *find_metadata(const std::string &key) const;
|
|
146
|
+
|
|
147
|
+
static std::unique_ptr<Entry> create(PathHierarchy hierarchy, std::shared_ptr<ArchiveStackOrchestrator> data_source_orchestrator, bool default_descent);
|
|
148
|
+
|
|
149
|
+
// Copy/move operations
|
|
150
|
+
Entry(const Entry &);
|
|
151
|
+
Entry &operator=(const Entry &);
|
|
152
|
+
Entry(Entry &&) noexcept;
|
|
153
|
+
Entry &operator=(Entry &&) noexcept;
|
|
154
|
+
|
|
155
|
+
~Entry();
|
|
156
|
+
|
|
157
|
+
private:
|
|
158
|
+
class Impl;
|
|
159
|
+
std::unique_ptr<Impl> _impl;
|
|
160
|
+
|
|
161
|
+
// Private constructor - only friends can create Entry objects
|
|
162
|
+
explicit Entry(Impl *impl);
|
|
163
|
+
Entry(const PathHierarchy &hierarchy, std::shared_ptr<ArchiveStackOrchestrator> data_source_orchestrator, bool default_descent);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
} // 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) = 0;
|
|
34
|
-
virtual int64_t size_of_single_part(const PathHierarchy &single_part) = 0;
|
|
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) = 0;
|
|
34
|
+
virtual int64_t size_of_single_part(const PathHierarchy &single_part) = 0;
|
|
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
|