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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/{LICENSE → LICENSE.txt} +77 -77
  3. data/README.md +103 -103
  4. data/ext/archive_r/Makefile +48 -45
  5. data/ext/archive_r/archive_r-x64-mingw-ucrt.def +2 -0
  6. data/ext/archive_r/archive_r_ext.cc +1106 -1106
  7. data/ext/archive_r/archive_r_ext.o +0 -0
  8. data/ext/archive_r/extconf.rb +120 -120
  9. data/ext/archive_r/mkmf.log +23 -18
  10. data/ext/archive_r/vendor/archive_r/LICENSE.txt +77 -77
  11. data/ext/archive_r/vendor/archive_r/include/archive_r/data_stream.h +52 -52
  12. data/ext/archive_r/vendor/archive_r/include/archive_r/entry.h +166 -166
  13. data/ext/archive_r/vendor/archive_r/include/archive_r/entry_fault.h +34 -34
  14. data/ext/archive_r/vendor/archive_r/include/archive_r/entry_metadata.h +56 -56
  15. data/ext/archive_r/vendor/archive_r/include/archive_r/multi_volume_stream_base.h +46 -46
  16. data/ext/archive_r/vendor/archive_r/include/archive_r/path_hierarchy.h +109 -109
  17. data/ext/archive_r/vendor/archive_r/include/archive_r/path_hierarchy_utils.h +37 -37
  18. data/ext/archive_r/vendor/archive_r/include/archive_r/platform_compat.h +19 -19
  19. data/ext/archive_r/vendor/archive_r/include/archive_r/traverser.h +122 -122
  20. data/ext/archive_r/vendor/archive_r/src/archive_stack_cursor.cc +330 -330
  21. data/ext/archive_r/vendor/archive_r/src/archive_stack_cursor.h +97 -97
  22. data/ext/archive_r/vendor/archive_r/src/archive_stack_orchestrator.cc +162 -162
  23. data/ext/archive_r/vendor/archive_r/src/archive_stack_orchestrator.h +54 -54
  24. data/ext/archive_r/vendor/archive_r/src/archive_type.cc +552 -552
  25. data/ext/archive_r/vendor/archive_r/src/archive_type.h +77 -77
  26. data/ext/archive_r/vendor/archive_r/src/data_stream.cc +35 -35
  27. data/ext/archive_r/vendor/archive_r/src/entry.cc +253 -253
  28. data/ext/archive_r/vendor/archive_r/src/entry_fault.cc +26 -26
  29. data/ext/archive_r/vendor/archive_r/src/entry_fault_error.cc +54 -54
  30. data/ext/archive_r/vendor/archive_r/src/entry_fault_error.h +32 -32
  31. data/ext/archive_r/vendor/archive_r/src/entry_impl.h +57 -57
  32. data/ext/archive_r/vendor/archive_r/src/multi_volume_manager.cc +81 -81
  33. data/ext/archive_r/vendor/archive_r/src/multi_volume_manager.h +41 -41
  34. data/ext/archive_r/vendor/archive_r/src/multi_volume_stream_base.cc +199 -199
  35. data/ext/archive_r/vendor/archive_r/src/path_hierarchy.cc +151 -151
  36. data/ext/archive_r/vendor/archive_r/src/path_hierarchy_utils.cc +304 -304
  37. data/ext/archive_r/vendor/archive_r/src/simple_profiler.h +120 -120
  38. data/ext/archive_r/vendor/archive_r/src/system_file_stream.cc +295 -295
  39. data/ext/archive_r/vendor/archive_r/src/system_file_stream.h +46 -46
  40. data/ext/archive_r/vendor/archive_r/src/traverser.cc +314 -314
  41. data/lib/archive_r.rb +105 -105
  42. metadata +11 -8
  43. data/ext/archive_r/archive_r.bundle +0 -0
@@ -1,32 +1,32 @@
1
- // SPDX-License-Identifier: MIT
2
- // Copyright (c) 2025 archive_r Team
3
-
4
- #pragma once
5
-
6
- #include "archive_r/entry_fault.h"
7
-
8
- #include <stdexcept>
9
- #include <string>
10
-
11
- namespace archive_r {
12
-
13
- class EntryFaultError : public std::runtime_error {
14
- public:
15
- explicit EntryFaultError(EntryFault fault);
16
- EntryFaultError(EntryFault fault, const std::string &internal_message);
17
-
18
- const EntryFault &fault() const noexcept { return _fault; }
19
- const PathHierarchy &hierarchy() const noexcept { return _fault.hierarchy; }
20
- int errno_value() const noexcept { return _fault.errno_value; }
21
-
22
- private:
23
- EntryFault _fault;
24
- };
25
-
26
- EntryFaultError make_entry_fault_error(const std::string &message, PathHierarchy hierarchy = {}, int errno_value = 0);
27
-
28
- std::string format_errno_error(const std::string &prefix, int err);
29
- std::string format_path_errno_error(const std::string &action, const std::string &path, int err);
30
- std::string prefer_error_detail(const std::string &detail, const std::string &fallback);
31
-
32
- } // namespace archive_r
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2025 archive_r Team
3
+
4
+ #pragma once
5
+
6
+ #include "archive_r/entry_fault.h"
7
+
8
+ #include <stdexcept>
9
+ #include <string>
10
+
11
+ namespace archive_r {
12
+
13
+ class EntryFaultError : public std::runtime_error {
14
+ public:
15
+ explicit EntryFaultError(EntryFault fault);
16
+ EntryFaultError(EntryFault fault, const std::string &internal_message);
17
+
18
+ const EntryFault &fault() const noexcept { return _fault; }
19
+ const PathHierarchy &hierarchy() const noexcept { return _fault.hierarchy; }
20
+ int errno_value() const noexcept { return _fault.errno_value; }
21
+
22
+ private:
23
+ EntryFault _fault;
24
+ };
25
+
26
+ EntryFaultError make_entry_fault_error(const std::string &message, PathHierarchy hierarchy = {}, int errno_value = 0);
27
+
28
+ std::string format_errno_error(const std::string &prefix, int err);
29
+ std::string format_path_errno_error(const std::string &action, const std::string &path, int err);
30
+ std::string prefer_error_detail(const std::string &detail, const std::string &fallback);
31
+
32
+ } // namespace archive_r
@@ -1,57 +1,57 @@
1
- // SPDX-License-Identifier: MIT
2
- // Copyright (c) 2025 archive_r Team
3
-
4
- #pragma once
5
-
6
- #include "archive_r/entry.h"
7
- #include "archive_stack_orchestrator.h"
8
- #include <filesystem>
9
- #include <memory>
10
- #include <optional>
11
- #include <unordered_set>
12
-
13
- namespace archive_r {
14
-
15
- // Entry implementation class - internal to Traverser
16
- class Entry::Impl {
17
- public:
18
- // Unified constructor - receives metadata directly
19
- // No libarchive dependency
20
- // Copy constructor and assignment (orchestrator is not copied)
21
- Impl(const Impl &other);
22
- Impl &operator=(const Impl &other);
23
-
24
- Impl(const PathHierarchy &hierarchy, std::shared_ptr<ArchiveStackOrchestrator> data_source_orchestrator, bool default_descent);
25
-
26
- std::string name() const;
27
- const PathHierarchy &path_hierarchy() const;
28
- bool is_directory() const;
29
- bool is_file() const;
30
- uint64_t size() const;
31
- size_t depth() const;
32
- void set_descent(bool enabled);
33
- bool descent_enabled() const;
34
- void set_multi_volume_group(const std::string &base_name, const MultiVolumeGroupOptions &options);
35
- ssize_t read(void *buffer, size_t length);
36
- const EntryMetadataMap &metadata() const;
37
- const EntryMetadataValue *metadata_value(const std::string &key) const;
38
-
39
- private:
40
- PathHierarchy _path_hierarchy;
41
-
42
- // Metadata only (no libarchive types)
43
- uint64_t _size;
44
- mode_t _filetype;
45
- EntryMetadataMap _metadata;
46
- bool _descend_enabled = true; // Flag to control automatic descent
47
-
48
- std::shared_ptr<ArchiveStackOrchestrator> _orchestrator; ///< Active orchestrator (shared with traverser or detached copy)
49
- bool _shares_traverser_orchestrator = false;
50
-
51
- mutable std::optional<ArchiveOption> _archive_options;
52
-
53
- void emit_fault(const std::string &message, int errno_value = 0) const;
54
- std::shared_ptr<ArchiveStackOrchestrator> ensure_orchestrator();
55
- };
56
-
57
- } // namespace archive_r
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2025 archive_r Team
3
+
4
+ #pragma once
5
+
6
+ #include "archive_r/entry.h"
7
+ #include "archive_stack_orchestrator.h"
8
+ #include <filesystem>
9
+ #include <memory>
10
+ #include <optional>
11
+ #include <unordered_set>
12
+
13
+ namespace archive_r {
14
+
15
+ // Entry implementation class - internal to Traverser
16
+ class Entry::Impl {
17
+ public:
18
+ // Unified constructor - receives metadata directly
19
+ // No libarchive dependency
20
+ // Copy constructor and assignment (orchestrator is not copied)
21
+ Impl(const Impl &other);
22
+ Impl &operator=(const Impl &other);
23
+
24
+ Impl(const PathHierarchy &hierarchy, std::shared_ptr<ArchiveStackOrchestrator> data_source_orchestrator, bool default_descent);
25
+
26
+ std::string name() const;
27
+ const PathHierarchy &path_hierarchy() const;
28
+ bool is_directory() const;
29
+ bool is_file() const;
30
+ uint64_t size() const;
31
+ size_t depth() const;
32
+ void set_descent(bool enabled);
33
+ bool descent_enabled() const;
34
+ void set_multi_volume_group(const std::string &base_name, const MultiVolumeGroupOptions &options);
35
+ ssize_t read(void *buffer, size_t length);
36
+ const EntryMetadataMap &metadata() const;
37
+ const EntryMetadataValue *metadata_value(const std::string &key) const;
38
+
39
+ private:
40
+ PathHierarchy _path_hierarchy;
41
+
42
+ // Metadata only (no libarchive types)
43
+ uint64_t _size;
44
+ mode_t _filetype;
45
+ EntryMetadataMap _metadata;
46
+ bool _descend_enabled = true; // Flag to control automatic descent
47
+
48
+ std::shared_ptr<ArchiveStackOrchestrator> _orchestrator; ///< Active orchestrator (shared with traverser or detached copy)
49
+ bool _shares_traverser_orchestrator = false;
50
+
51
+ mutable std::optional<ArchiveOption> _archive_options;
52
+
53
+ void emit_fault(const std::string &message, int errno_value = 0) const;
54
+ std::shared_ptr<ArchiveStackOrchestrator> ensure_orchestrator();
55
+ };
56
+
57
+ } // namespace archive_r
@@ -1,81 +1,81 @@
1
- // SPDX-License-Identifier: MIT
2
- // Copyright (c) 2025 archive_r Team
3
-
4
- #include "multi_volume_manager.h"
5
-
6
- #include "archive_r/path_hierarchy_utils.h"
7
-
8
- #include <algorithm>
9
- #include <utility>
10
-
11
- namespace archive_r {
12
-
13
- MultiVolumeManager::MultiVolumeGroup &MultiVolumeManager::get_or_create_multi_volume_group(const PathHierarchy &parent_hierarchy,
14
- const std::string &base_name,
15
- PathEntry::Parts::Ordering ordering) {
16
- GroupList &groups = _multi_volume_groups[parent_hierarchy];
17
- auto it = std::find_if(groups.begin(), groups.end(), [&](const MultiVolumeGroup &group) { return group.base_name == base_name; });
18
-
19
- if (it == groups.end()) {
20
- MultiVolumeGroup group;
21
- group.base_name = base_name;
22
- group.parent_hierarchy = parent_hierarchy;
23
- group.ordering = ordering;
24
- groups.push_back(std::move(group));
25
- return groups.back();
26
- }
27
-
28
- MultiVolumeGroup &target = *it;
29
- if (ordering == PathEntry::Parts::Ordering::Given) {
30
- target.ordering = PathEntry::Parts::Ordering::Given;
31
- }
32
- return target;
33
- }
34
-
35
- bool MultiVolumeManager::pop_group_for_parent(const PathHierarchy &parent_hierarchy, MultiVolumeGroup &out_group) {
36
- ParentGroupMap::iterator it = _multi_volume_groups.find(parent_hierarchy);
37
- if (it == _multi_volume_groups.end() || it->second.empty()) {
38
- return false;
39
- }
40
-
41
- out_group = it->second.front();
42
- it->second.erase(it->second.begin());
43
- if (it->second.empty()) {
44
- _multi_volume_groups.erase(it);
45
- }
46
-
47
- return true;
48
- }
49
-
50
- void MultiVolumeManager::mark_entry_as_multi_volume(const PathHierarchy &entry_path, const std::string &base_name,
51
- PathEntry::Parts::Ordering ordering) {
52
- if (entry_path.empty() || pathhierarchy_is_multivolume(entry_path)) {
53
- return;
54
- }
55
-
56
- MultiVolumeGroup &target = get_or_create_multi_volume_group(parent_hierarchy(entry_path), base_name, ordering);
57
- auto &parts = target.parts;
58
- const bool exists = std::any_of(parts.begin(), parts.end(), [&](const PathHierarchy &existing) {
59
- return hierarchies_equal(existing, entry_path);
60
- });
61
- if (!exists) {
62
- parts.push_back(entry_path);
63
- }
64
- }
65
-
66
- bool MultiVolumeManager::pop_multi_volume_group(const PathHierarchy &current_hierarchy, PathHierarchy &multi_volume_hierarchy) {
67
- MultiVolumeGroup group;
68
- if (!pop_group_for_parent(current_hierarchy, group)) {
69
- return false;
70
- }
71
-
72
- if (group.ordering != PathEntry::Parts::Ordering::Given) {
73
- sort_hierarchies(group.parts);
74
- }
75
-
76
- multi_volume_hierarchy = merge_multi_volume_sources(group.parts);
77
- multi_volume_hierarchy.back().multi_volume_parts_mut().ordering = group.ordering;
78
- return true;
79
- }
80
-
81
- } // namespace archive_r
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2025 archive_r Team
3
+
4
+ #include "multi_volume_manager.h"
5
+
6
+ #include "archive_r/path_hierarchy_utils.h"
7
+
8
+ #include <algorithm>
9
+ #include <utility>
10
+
11
+ namespace archive_r {
12
+
13
+ MultiVolumeManager::MultiVolumeGroup &MultiVolumeManager::get_or_create_multi_volume_group(const PathHierarchy &parent_hierarchy,
14
+ const std::string &base_name,
15
+ PathEntry::Parts::Ordering ordering) {
16
+ GroupList &groups = _multi_volume_groups[parent_hierarchy];
17
+ auto it = std::find_if(groups.begin(), groups.end(), [&](const MultiVolumeGroup &group) { return group.base_name == base_name; });
18
+
19
+ if (it == groups.end()) {
20
+ MultiVolumeGroup group;
21
+ group.base_name = base_name;
22
+ group.parent_hierarchy = parent_hierarchy;
23
+ group.ordering = ordering;
24
+ groups.push_back(std::move(group));
25
+ return groups.back();
26
+ }
27
+
28
+ MultiVolumeGroup &target = *it;
29
+ if (ordering == PathEntry::Parts::Ordering::Given) {
30
+ target.ordering = PathEntry::Parts::Ordering::Given;
31
+ }
32
+ return target;
33
+ }
34
+
35
+ bool MultiVolumeManager::pop_group_for_parent(const PathHierarchy &parent_hierarchy, MultiVolumeGroup &out_group) {
36
+ ParentGroupMap::iterator it = _multi_volume_groups.find(parent_hierarchy);
37
+ if (it == _multi_volume_groups.end() || it->second.empty()) {
38
+ return false;
39
+ }
40
+
41
+ out_group = it->second.front();
42
+ it->second.erase(it->second.begin());
43
+ if (it->second.empty()) {
44
+ _multi_volume_groups.erase(it);
45
+ }
46
+
47
+ return true;
48
+ }
49
+
50
+ void MultiVolumeManager::mark_entry_as_multi_volume(const PathHierarchy &entry_path, const std::string &base_name,
51
+ PathEntry::Parts::Ordering ordering) {
52
+ if (entry_path.empty() || pathhierarchy_is_multivolume(entry_path)) {
53
+ return;
54
+ }
55
+
56
+ MultiVolumeGroup &target = get_or_create_multi_volume_group(parent_hierarchy(entry_path), base_name, ordering);
57
+ auto &parts = target.parts;
58
+ const bool exists = std::any_of(parts.begin(), parts.end(), [&](const PathHierarchy &existing) {
59
+ return hierarchies_equal(existing, entry_path);
60
+ });
61
+ if (!exists) {
62
+ parts.push_back(entry_path);
63
+ }
64
+ }
65
+
66
+ bool MultiVolumeManager::pop_multi_volume_group(const PathHierarchy &current_hierarchy, PathHierarchy &multi_volume_hierarchy) {
67
+ MultiVolumeGroup group;
68
+ if (!pop_group_for_parent(current_hierarchy, group)) {
69
+ return false;
70
+ }
71
+
72
+ if (group.ordering != PathEntry::Parts::Ordering::Given) {
73
+ sort_hierarchies(group.parts);
74
+ }
75
+
76
+ multi_volume_hierarchy = merge_multi_volume_sources(group.parts);
77
+ multi_volume_hierarchy.back().multi_volume_parts_mut().ordering = group.ordering;
78
+ return true;
79
+ }
80
+
81
+ } // namespace archive_r
@@ -1,41 +1,41 @@
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_type.h"
8
-
9
- #include <map>
10
- #include <string>
11
- #include <vector>
12
-
13
- namespace archive_r {
14
-
15
- class MultiVolumeManager {
16
- public:
17
- struct MultiVolumeGroup {
18
- std::vector<PathHierarchy> parts;
19
- std::string base_name;
20
- PathHierarchy parent_hierarchy;
21
- PathEntry::Parts::Ordering ordering = PathEntry::Parts::Ordering::Natural;
22
- };
23
-
24
- using GroupList = std::vector<MultiVolumeGroup>;
25
- using ParentGroupMap = std::map<PathHierarchy, GroupList, PathHierarchyLess>;
26
-
27
- void mark_entry_as_multi_volume(const PathHierarchy &entry_path, const std::string &base_name,
28
- PathEntry::Parts::Ordering ordering = PathEntry::Parts::Ordering::Natural);
29
-
30
- bool pop_multi_volume_group(const PathHierarchy &current_hierarchy, PathHierarchy &multi_volume_hierarchy);
31
-
32
- private:
33
- MultiVolumeGroup &get_or_create_multi_volume_group(const PathHierarchy &parent_hierarchy, const std::string &base_name,
34
- PathEntry::Parts::Ordering ordering);
35
-
36
- bool pop_group_for_parent(const PathHierarchy &parent_hierarchy, MultiVolumeGroup &out_group);
37
-
38
- ParentGroupMap _multi_volume_groups;
39
- };
40
-
41
- } // 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_type.h"
8
+
9
+ #include <map>
10
+ #include <string>
11
+ #include <vector>
12
+
13
+ namespace archive_r {
14
+
15
+ class MultiVolumeManager {
16
+ public:
17
+ struct MultiVolumeGroup {
18
+ std::vector<PathHierarchy> parts;
19
+ std::string base_name;
20
+ PathHierarchy parent_hierarchy;
21
+ PathEntry::Parts::Ordering ordering = PathEntry::Parts::Ordering::Natural;
22
+ };
23
+
24
+ using GroupList = std::vector<MultiVolumeGroup>;
25
+ using ParentGroupMap = std::map<PathHierarchy, GroupList, PathHierarchyLess>;
26
+
27
+ void mark_entry_as_multi_volume(const PathHierarchy &entry_path, const std::string &base_name,
28
+ PathEntry::Parts::Ordering ordering = PathEntry::Parts::Ordering::Natural);
29
+
30
+ bool pop_multi_volume_group(const PathHierarchy &current_hierarchy, PathHierarchy &multi_volume_hierarchy);
31
+
32
+ private:
33
+ MultiVolumeGroup &get_or_create_multi_volume_group(const PathHierarchy &parent_hierarchy, const std::string &base_name,
34
+ PathEntry::Parts::Ordering ordering);
35
+
36
+ bool pop_group_for_parent(const PathHierarchy &parent_hierarchy, MultiVolumeGroup &out_group);
37
+
38
+ ParentGroupMap _multi_volume_groups;
39
+ };
40
+
41
+ } // namespace archive_r