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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b1e3a5853dd7529b8081a526efbbcd9327348647468cb600d40a153d9e38d659
|
|
4
|
+
data.tar.gz: 10d49f6b6bba5dc5e46d87b52b33e8a3a2c442f271b2875bb3c7138c51fff2a1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6dc55854a365cb7d18f1f511b3ff2812599bea39540c7f61ff8abf7ab319284d93907cfb22ba8edb03147c8b3456b54e8747f665cf49fb09b233b6e58a7c9ae1
|
|
7
|
+
data.tar.gz: 768b91d065d112ade3459149fd38aed07d981703cd7640722b1c2aa7f0ddd1b03e53a317578bbba42069d4a67519dbc975266b7e8e6b03ab1d4a3227b341ca0a
|
data/{LICENSE → LICENSE.txt}
RENAMED
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
archive_r License
|
|
2
|
-
Version: 0.1.3 (2025-12-02)
|
|
3
|
-
|
|
4
|
-
----------------------------------------
|
|
5
|
-
Primary License
|
|
6
|
-
----------------------------------------
|
|
7
|
-
|
|
8
|
-
MIT License
|
|
9
|
-
|
|
10
|
-
Copyright (c) 2025 archive_r Team
|
|
11
|
-
|
|
12
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
-
in the Software without restriction, including without limitation the rights
|
|
15
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
-
furnished to do so, subject to the following conditions:
|
|
18
|
-
|
|
19
|
-
The above copyright notice and this permission notice shall be included in all
|
|
20
|
-
copies or substantial portions of the Software.
|
|
21
|
-
|
|
22
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
-
SOFTWARE.
|
|
29
|
-
|
|
30
|
-
----------------------------------------
|
|
31
|
-
Third-Party Notices
|
|
32
|
-
----------------------------------------
|
|
33
|
-
|
|
34
|
-
This distribution bundles or links against the following third-party
|
|
35
|
-
components. Their respective license terms apply in addition to the MIT
|
|
36
|
-
License shown above.
|
|
37
|
-
|
|
38
|
-
1. libarchive
|
|
39
|
-
- Purpose: core archive reading and writing functionality for the C++
|
|
40
|
-
library and language bindings.
|
|
41
|
-
- License: New BSD License (https://www.libarchive.org/)
|
|
42
|
-
|
|
43
|
-
2. pybind11
|
|
44
|
-
- Purpose: header-only binding generator for the Python extension module.
|
|
45
|
-
- License: BSD-style License (https://github.com/pybind/pybind11)
|
|
46
|
-
|
|
47
|
-
The following components are redistributed only because libarchive (bundled with archive_r) depends on them at runtime:
|
|
48
|
-
|
|
49
|
-
3. zlib
|
|
50
|
-
- Purpose: libarchive dependency providing DEFLATE compression; bundled inside archive_r binaries and wheels because libarchive requires it.
|
|
51
|
-
- License: zlib License (https://zlib.net/zlib_license.html)
|
|
52
|
-
|
|
53
|
-
4. bzip2
|
|
54
|
-
- Purpose: libarchive dependency providing bzip2 compression support; distributed with archive_r artifacts.
|
|
55
|
-
- License: BSD-style license (https://sourceware.org/bzip2/)
|
|
56
|
-
|
|
57
|
-
5. liblzma (XZ Utils)
|
|
58
|
-
- Purpose: libarchive dependency providing LZMA/XZ compression; included with archive_r packages.
|
|
59
|
-
- License: Public Domain + GNU LGPLv2.1+ (https://tukaani.org/xz/)
|
|
60
|
-
|
|
61
|
-
6. libxml2
|
|
62
|
-
- Purpose: libarchive dependency used for archive formats such as xar; distributed alongside archive_r.
|
|
63
|
-
- License: MIT-style License (http://xmlsoft.org/)
|
|
64
|
-
|
|
65
|
-
7. zstd
|
|
66
|
-
- Purpose: libarchive dependency providing Zstandard compression; shipped within archive_r binaries.
|
|
67
|
-
- License: BSD License (https://github.com/facebook/zstd)
|
|
68
|
-
|
|
69
|
-
8. OpenSSL 3
|
|
70
|
-
- Purpose: libarchive dependency providing cryptographic support for encrypted archives; included with archive_r packages.
|
|
71
|
-
- License: Apache License 2.0 with OpenSSL exception (https://www.openssl.org/source/license.html)
|
|
72
|
-
|
|
73
|
-
9. libiconv / libcharset
|
|
74
|
-
- Purpose: libxml2/libarchive dependency for character set conversion; redistributed with archive_r artifacts.
|
|
75
|
-
- License: GNU LGPLv2.1+ (https://www.gnu.org/software/libiconv/)
|
|
76
|
-
Users of archive_r should review the linked third-party licenses to ensure
|
|
77
|
-
compliance with their terms when redistributing this software.
|
|
1
|
+
archive_r License
|
|
2
|
+
Version: 0.1.3 (2025-12-02)
|
|
3
|
+
|
|
4
|
+
----------------------------------------
|
|
5
|
+
Primary License
|
|
6
|
+
----------------------------------------
|
|
7
|
+
|
|
8
|
+
MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2025 archive_r Team
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
|
|
30
|
+
----------------------------------------
|
|
31
|
+
Third-Party Notices
|
|
32
|
+
----------------------------------------
|
|
33
|
+
|
|
34
|
+
This distribution bundles or links against the following third-party
|
|
35
|
+
components. Their respective license terms apply in addition to the MIT
|
|
36
|
+
License shown above.
|
|
37
|
+
|
|
38
|
+
1. libarchive
|
|
39
|
+
- Purpose: core archive reading and writing functionality for the C++
|
|
40
|
+
library and language bindings.
|
|
41
|
+
- License: New BSD License (https://www.libarchive.org/)
|
|
42
|
+
|
|
43
|
+
2. pybind11
|
|
44
|
+
- Purpose: header-only binding generator for the Python extension module.
|
|
45
|
+
- License: BSD-style License (https://github.com/pybind/pybind11)
|
|
46
|
+
|
|
47
|
+
The following components are redistributed only because libarchive (bundled with archive_r) depends on them at runtime:
|
|
48
|
+
|
|
49
|
+
3. zlib
|
|
50
|
+
- Purpose: libarchive dependency providing DEFLATE compression; bundled inside archive_r binaries and wheels because libarchive requires it.
|
|
51
|
+
- License: zlib License (https://zlib.net/zlib_license.html)
|
|
52
|
+
|
|
53
|
+
4. bzip2
|
|
54
|
+
- Purpose: libarchive dependency providing bzip2 compression support; distributed with archive_r artifacts.
|
|
55
|
+
- License: BSD-style license (https://sourceware.org/bzip2/)
|
|
56
|
+
|
|
57
|
+
5. liblzma (XZ Utils)
|
|
58
|
+
- Purpose: libarchive dependency providing LZMA/XZ compression; included with archive_r packages.
|
|
59
|
+
- License: Public Domain + GNU LGPLv2.1+ (https://tukaani.org/xz/)
|
|
60
|
+
|
|
61
|
+
6. libxml2
|
|
62
|
+
- Purpose: libarchive dependency used for archive formats such as xar; distributed alongside archive_r.
|
|
63
|
+
- License: MIT-style License (http://xmlsoft.org/)
|
|
64
|
+
|
|
65
|
+
7. zstd
|
|
66
|
+
- Purpose: libarchive dependency providing Zstandard compression; shipped within archive_r binaries.
|
|
67
|
+
- License: BSD License (https://github.com/facebook/zstd)
|
|
68
|
+
|
|
69
|
+
8. OpenSSL 3
|
|
70
|
+
- Purpose: libarchive dependency providing cryptographic support for encrypted archives; included with archive_r packages.
|
|
71
|
+
- License: Apache License 2.0 with OpenSSL exception (https://www.openssl.org/source/license.html)
|
|
72
|
+
|
|
73
|
+
9. libiconv / libcharset
|
|
74
|
+
- Purpose: libxml2/libarchive dependency for character set conversion; redistributed with archive_r artifacts.
|
|
75
|
+
- License: GNU LGPLv2.1+ (https://www.gnu.org/software/libiconv/)
|
|
76
|
+
Users of archive_r should review the linked third-party licenses to ensure
|
|
77
|
+
compliance with their terms when redistributing this software.
|
data/README.md
CHANGED
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
# archive_r Ruby Binding
|
|
2
|
-
|
|
3
|
-
Ruby bindings expose the archive_r traverser API with a natural, block-friendly interface. This document consolidates the Ruby-specific instructions that previously lived in the repository root README.
|
|
4
|
-
|
|
5
|
-
## Requirements
|
|
6
|
-
|
|
7
|
-
- Ruby 3.2 (same toolchain as the development environment)
|
|
8
|
-
- libarchive 3.x (shared library and headers)
|
|
9
|
-
- Build tools: `rake`, `minitest`, a C++17 compiler, and `make`
|
|
10
|
-
|
|
11
|
-
## Installing the Gem
|
|
12
|
-
|
|
13
|
-
### Recommended: build.sh workflow
|
|
14
|
-
|
|
15
|
-
1. From the repository root run:
|
|
16
|
-
```bash
|
|
17
|
-
./build.sh --with-ruby
|
|
18
|
-
```
|
|
19
|
-
Ruby packaging is enabled by default, so the command above builds the core library, compiles the binding, and creates `build/bindings/ruby/archive_r-<version>.gem`.
|
|
20
|
-
2. Install the freshly built gem into your desired GEM_HOME:
|
|
21
|
-
```bash
|
|
22
|
-
gem install --local build/bindings/ruby/archive_r-*.gem
|
|
23
|
-
```
|
|
24
|
-
3. When developing inside this repository the tests automatically install the gem into `build/ruby_gem_home` and set `ARCHIVE_R_CORE_ROOT=build` so the native extension links against the just-built static library.
|
|
25
|
-
|
|
26
|
-
### Working inside bindings/ruby
|
|
27
|
-
|
|
28
|
-
If you prefer to build from the `bindings/ruby` directory:
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
cd bindings/ruby
|
|
32
|
-
bundle install
|
|
33
|
-
bundle exec rake compile # builds ext/archive_r
|
|
34
|
-
bundle exec rake test # runs test/test_traverser.rb
|
|
35
|
-
bundle exec rake build # creates archive_r-<version>.gem locally
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
The `rake test` task compiles the extension, installs it into `lib/`, and executes the Minitest suite.
|
|
39
|
-
|
|
40
|
-
## Running the full repository test suite
|
|
41
|
-
|
|
42
|
-
`./run_tests.sh` prepares a clean GEM_HOME (`build/ruby_gem_home`), installs the gem produced in `build/bindings/ruby`, and runs `bindings/ruby/test/test_traverser.rb`. The script now streams the `gem install` log to the console and preserves it in `build/logs/ruby_gem_install.log` for later inspection.
|
|
43
|
-
|
|
44
|
-
## Usage Example
|
|
45
|
-
|
|
46
|
-
```ruby
|
|
47
|
-
require 'archive_r'
|
|
48
|
-
|
|
49
|
-
SAFE_FORMATS = Archive_r::STANDARD_FORMATS
|
|
50
|
-
|
|
51
|
-
def search_in_entry(entry, keyword)
|
|
52
|
-
overlap = ''
|
|
53
|
-
loop do
|
|
54
|
-
chunk = entry.read(8192)
|
|
55
|
-
break if chunk.nil? || chunk.empty?
|
|
56
|
-
|
|
57
|
-
search_text = overlap + chunk
|
|
58
|
-
return true if search_text.include?(keyword)
|
|
59
|
-
|
|
60
|
-
overlap = if chunk.length >= keyword.length - 1
|
|
61
|
-
chunk[-(keyword.length - 1)..-1]
|
|
62
|
-
else
|
|
63
|
-
chunk
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
false
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
Archive_r.traverse('test.zip', formats: SAFE_FORMATS) do |entry|
|
|
70
|
-
puts "#{entry.path} (depth=#{entry.depth})"
|
|
71
|
-
next unless entry.file? && entry.path.end_with?('.txt')
|
|
72
|
-
puts " Found keyword" if search_in_entry(entry, 'search_keyword')
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
Archive_r.traverse('protected.zip', passphrases: ['password123'], formats: SAFE_FORMATS) do |entry|
|
|
76
|
-
puts entry.path
|
|
77
|
-
end
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## Thread Safety
|
|
81
|
-
|
|
82
|
-
The Ruby bindings follow the same thread-safety rules as the C++ core library:
|
|
83
|
-
|
|
84
|
-
**Safe:**
|
|
85
|
-
- Each thread creates and uses its own `Traverser` instance
|
|
86
|
-
- Concurrent traversal of different archives from different threads
|
|
87
|
-
|
|
88
|
-
**Unsafe:**
|
|
89
|
-
- Sharing a single `Traverser` instance across multiple threads
|
|
90
|
-
- Calling `Archive_r.register_stream_factory` or `Archive_r.on_fault` from multiple threads (these modify process-wide global state)
|
|
91
|
-
|
|
92
|
-
**Summary:** Create one `Traverser` per thread. Do not call global configuration methods (`register_stream_factory`, `on_fault`) concurrently.
|
|
93
|
-
|
|
94
|
-
## Environment Notes
|
|
95
|
-
|
|
96
|
-
- Set `ARCHIVE_R_CORE_ROOT` to the repository `build/` directory (or another archive_r build) if the gem needs to link against a pre-built static library instead of compiling the vendored core sources.
|
|
97
|
-
- When installing into a sandbox (e.g., CI), configure `GEM_HOME`/`GEM_PATH` before invoking `gem install` so that the extension picks up the correct core library.
|
|
98
|
-
|
|
99
|
-
## Further Help
|
|
100
|
-
|
|
101
|
-
- Issue tracker: <https://github.com/raizo-tcs/archive_r/issues>
|
|
102
|
-
- Releases / changelog: <https://github.com/raizo-tcs/archive_r/releases>
|
|
103
|
-
- For C++/Python usage and overall project information, see the repository root `README.md`.
|
|
1
|
+
# archive_r Ruby Binding
|
|
2
|
+
|
|
3
|
+
Ruby bindings expose the archive_r traverser API with a natural, block-friendly interface. This document consolidates the Ruby-specific instructions that previously lived in the repository root README.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Ruby 3.2 (same toolchain as the development environment)
|
|
8
|
+
- libarchive 3.x (shared library and headers)
|
|
9
|
+
- Build tools: `rake`, `minitest`, a C++17 compiler, and `make`
|
|
10
|
+
|
|
11
|
+
## Installing the Gem
|
|
12
|
+
|
|
13
|
+
### Recommended: build.sh workflow
|
|
14
|
+
|
|
15
|
+
1. From the repository root run:
|
|
16
|
+
```bash
|
|
17
|
+
./build.sh --with-ruby
|
|
18
|
+
```
|
|
19
|
+
Ruby packaging is enabled by default, so the command above builds the core library, compiles the binding, and creates `build/bindings/ruby/archive_r-<version>.gem`.
|
|
20
|
+
2. Install the freshly built gem into your desired GEM_HOME:
|
|
21
|
+
```bash
|
|
22
|
+
gem install --local build/bindings/ruby/archive_r-*.gem
|
|
23
|
+
```
|
|
24
|
+
3. When developing inside this repository the tests automatically install the gem into `build/ruby_gem_home` and set `ARCHIVE_R_CORE_ROOT=build` so the native extension links against the just-built static library.
|
|
25
|
+
|
|
26
|
+
### Working inside bindings/ruby
|
|
27
|
+
|
|
28
|
+
If you prefer to build from the `bindings/ruby` directory:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
cd bindings/ruby
|
|
32
|
+
bundle install
|
|
33
|
+
bundle exec rake compile # builds ext/archive_r
|
|
34
|
+
bundle exec rake test # runs test/test_traverser.rb
|
|
35
|
+
bundle exec rake build # creates archive_r-<version>.gem locally
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The `rake test` task compiles the extension, installs it into `lib/`, and executes the Minitest suite.
|
|
39
|
+
|
|
40
|
+
## Running the full repository test suite
|
|
41
|
+
|
|
42
|
+
`./run_tests.sh` prepares a clean GEM_HOME (`build/ruby_gem_home`), installs the gem produced in `build/bindings/ruby`, and runs `bindings/ruby/test/test_traverser.rb`. The script now streams the `gem install` log to the console and preserves it in `build/logs/ruby_gem_install.log` for later inspection.
|
|
43
|
+
|
|
44
|
+
## Usage Example
|
|
45
|
+
|
|
46
|
+
```ruby
|
|
47
|
+
require 'archive_r'
|
|
48
|
+
|
|
49
|
+
SAFE_FORMATS = Archive_r::STANDARD_FORMATS
|
|
50
|
+
|
|
51
|
+
def search_in_entry(entry, keyword)
|
|
52
|
+
overlap = ''
|
|
53
|
+
loop do
|
|
54
|
+
chunk = entry.read(8192)
|
|
55
|
+
break if chunk.nil? || chunk.empty?
|
|
56
|
+
|
|
57
|
+
search_text = overlap + chunk
|
|
58
|
+
return true if search_text.include?(keyword)
|
|
59
|
+
|
|
60
|
+
overlap = if chunk.length >= keyword.length - 1
|
|
61
|
+
chunk[-(keyword.length - 1)..-1]
|
|
62
|
+
else
|
|
63
|
+
chunk
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
false
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
Archive_r.traverse('test.zip', formats: SAFE_FORMATS) do |entry|
|
|
70
|
+
puts "#{entry.path} (depth=#{entry.depth})"
|
|
71
|
+
next unless entry.file? && entry.path.end_with?('.txt')
|
|
72
|
+
puts " Found keyword" if search_in_entry(entry, 'search_keyword')
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
Archive_r.traverse('protected.zip', passphrases: ['password123'], formats: SAFE_FORMATS) do |entry|
|
|
76
|
+
puts entry.path
|
|
77
|
+
end
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Thread Safety
|
|
81
|
+
|
|
82
|
+
The Ruby bindings follow the same thread-safety rules as the C++ core library:
|
|
83
|
+
|
|
84
|
+
**Safe:**
|
|
85
|
+
- Each thread creates and uses its own `Traverser` instance
|
|
86
|
+
- Concurrent traversal of different archives from different threads
|
|
87
|
+
|
|
88
|
+
**Unsafe:**
|
|
89
|
+
- Sharing a single `Traverser` instance across multiple threads
|
|
90
|
+
- Calling `Archive_r.register_stream_factory` or `Archive_r.on_fault` from multiple threads (these modify process-wide global state)
|
|
91
|
+
|
|
92
|
+
**Summary:** Create one `Traverser` per thread. Do not call global configuration methods (`register_stream_factory`, `on_fault`) concurrently.
|
|
93
|
+
|
|
94
|
+
## Environment Notes
|
|
95
|
+
|
|
96
|
+
- Set `ARCHIVE_R_CORE_ROOT` to the repository `build/` directory (or another archive_r build) if the gem needs to link against a pre-built static library instead of compiling the vendored core sources.
|
|
97
|
+
- When installing into a sandbox (e.g., CI), configure `GEM_HOME`/`GEM_PATH` before invoking `gem install` so that the extension picks up the correct core library.
|
|
98
|
+
|
|
99
|
+
## Further Help
|
|
100
|
+
|
|
101
|
+
- Issue tracker: <https://github.com/raizo-tcs/archive_r/issues>
|
|
102
|
+
- Releases / changelog: <https://github.com/raizo-tcs/archive_r/releases>
|
|
103
|
+
- For C++/Python usage and overall project information, see the repository root `README.md`.
|
data/ext/archive_r/Makefile
CHANGED
|
@@ -13,12 +13,12 @@ NULLCMD = :
|
|
|
13
13
|
#### Start of system configuration section. ####
|
|
14
14
|
|
|
15
15
|
srcdir = .
|
|
16
|
-
topdir = /
|
|
16
|
+
topdir = /C/hostedtoolcache/windows/Ruby/3.2.9/x64/include/ruby-3.2.0
|
|
17
17
|
hdrdir = $(topdir)
|
|
18
|
-
arch_hdrdir = /
|
|
18
|
+
arch_hdrdir = /C/hostedtoolcache/windows/Ruby/3.2.9/x64/include/ruby-3.2.0/x64-mingw-ucrt
|
|
19
19
|
PATH_SEPARATOR = :
|
|
20
|
-
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
|
|
21
|
-
prefix = $(DESTDIR)/
|
|
20
|
+
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby:;:D:/a/archive_r/archive_r/src
|
|
21
|
+
prefix = $(DESTDIR)/C/hostedtoolcache/windows/Ruby/3.2.9/x64
|
|
22
22
|
rubysitearchprefix = $(rubylibprefix)/$(sitearch)
|
|
23
23
|
rubyarchprefix = $(rubylibprefix)/$(arch)
|
|
24
24
|
rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
|
|
@@ -31,10 +31,10 @@ sitehdrdir = $(rubyhdrdir)/site_ruby
|
|
|
31
31
|
rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
|
|
32
32
|
vendorarchdir = $(vendorlibdir)/$(sitearch)
|
|
33
33
|
vendorlibdir = $(vendordir)/$(ruby_version)
|
|
34
|
-
vendordir = $(
|
|
34
|
+
vendordir = $(rubylibprefix)/vendor_ruby
|
|
35
35
|
sitearchdir = $(sitelibdir)/$(sitearch)
|
|
36
36
|
sitelibdir = $(sitedir)/$(ruby_version)
|
|
37
|
-
sitedir = $(
|
|
37
|
+
sitedir = $(rubylibprefix)/site_ruby
|
|
38
38
|
rubyarchdir = $(rubylibdir)/$(arch)
|
|
39
39
|
rubylibdir = $(rubylibprefix)/$(ruby_version)
|
|
40
40
|
sitearchincludedir = $(includedir)/$(sitearch)
|
|
@@ -56,7 +56,7 @@ includedir = $(prefix)/include
|
|
|
56
56
|
runstatedir = $(localstatedir)/run
|
|
57
57
|
localstatedir = $(prefix)/var
|
|
58
58
|
sharedstatedir = $(prefix)/com
|
|
59
|
-
sysconfdir = $(
|
|
59
|
+
sysconfdir = $(DESTDIR)
|
|
60
60
|
datadir = $(datarootdir)
|
|
61
61
|
datarootdir = $(prefix)/share
|
|
62
62
|
libexecdir = $(exec_prefix)/libexec
|
|
@@ -66,58 +66,58 @@ archdir = $(rubyarchdir)
|
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
CC_WRAPPER =
|
|
69
|
-
CC =
|
|
70
|
-
CXX =
|
|
71
|
-
LIBRUBY = $(
|
|
69
|
+
CC = gcc
|
|
70
|
+
CXX = g++
|
|
71
|
+
LIBRUBY = lib$(RUBY_SO_NAME).dll.a
|
|
72
72
|
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
|
73
73
|
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
|
|
74
|
-
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
|
|
74
|
+
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static $(MAINLIBS)
|
|
75
75
|
empty =
|
|
76
76
|
OUTFLAG = -o $(empty)
|
|
77
77
|
COUTFLAG = -o $(empty)
|
|
78
78
|
CSRCFLAG = $(empty)
|
|
79
79
|
|
|
80
80
|
RUBY_EXTCONF_H =
|
|
81
|
-
cflags =
|
|
81
|
+
cflags = $(optflags) $(debugflags) $(warnflags)
|
|
82
82
|
cxxflags =
|
|
83
|
-
optflags = -O3 -fno-fast-math
|
|
83
|
+
optflags = -O3 -fno-omit-frame-pointer -fno-fast-math
|
|
84
84
|
debugflags = -ggdb3
|
|
85
|
-
warnflags = -Wall -Wextra -
|
|
85
|
+
warnflags = -Wall -Wextra -Wdeprecated-declarations -Wdiv-by-zero -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wold-style-definition -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef
|
|
86
86
|
cppflags =
|
|
87
|
-
CCDLFLAGS =
|
|
88
|
-
CFLAGS = $(CCDLFLAGS)
|
|
89
|
-
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir) -
|
|
90
|
-
DEFS =
|
|
91
|
-
CPPFLAGS = -
|
|
92
|
-
CXXFLAGS = $(CCDLFLAGS) -
|
|
93
|
-
ldflags = -L. -fstack-protector-strong -
|
|
94
|
-
dldflags = -
|
|
95
|
-
ARCH_FLAG =
|
|
87
|
+
CCDLFLAGS =
|
|
88
|
+
CFLAGS = $(CCDLFLAGS) -O3 -fno-fast-math -fstack-protector-strong $(ARCH_FLAG)
|
|
89
|
+
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir) -ID:/a/archive_r/archive_r/include -ID:/a/archive_r/archive_r/src -IC:/vcpkg/installed/x64-windows/include
|
|
90
|
+
DEFS = -D_FILE_OFFSET_BITS=64
|
|
91
|
+
CPPFLAGS = -IC:\vcpkg\installed\x64-windows/include -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0600 -D__MINGW_USE_VC2005_COMPAT $(DEFS) $(cppflags)
|
|
92
|
+
CXXFLAGS = $(CCDLFLAGS) -march=nocona -msahf -mtune=generic -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong -Wp,-D__USE_MINGW_ANSI_STDIO=1 -std=c++17 $(ARCH_FLAG)
|
|
93
|
+
ldflags = -L. -pipe -s -fstack-protector-strong -Wl,--no-as-needed
|
|
94
|
+
dldflags = -pipe -s -fstack-protector-strong -Wl,--enable-auto-image-base,--enable-auto-import $(DEFFILE)
|
|
95
|
+
ARCH_FLAG = -m64
|
|
96
96
|
DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
|
|
97
|
-
LDSHARED = $(CC) -
|
|
98
|
-
LDSHAREDXX = $(CXX) -
|
|
99
|
-
AR = ar
|
|
100
|
-
EXEEXT =
|
|
97
|
+
LDSHARED = $(CC) -shared
|
|
98
|
+
LDSHAREDXX = $(CXX) -shared
|
|
99
|
+
AR = gcc-ar
|
|
100
|
+
EXEEXT = .exe
|
|
101
101
|
|
|
102
102
|
RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
|
|
103
|
-
RUBY_SO_NAME =
|
|
104
|
-
RUBYW_INSTALL_NAME =
|
|
103
|
+
RUBY_SO_NAME = x64-ucrt-ruby320
|
|
104
|
+
RUBYW_INSTALL_NAME = $(RUBYW_BASE_NAME)
|
|
105
105
|
RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
|
|
106
106
|
RUBYW_BASE_NAME = rubyw
|
|
107
107
|
RUBY_BASE_NAME = ruby
|
|
108
108
|
|
|
109
|
-
arch =
|
|
110
|
-
sitearch =
|
|
111
|
-
ruby_version = 3.
|
|
109
|
+
arch = x64-mingw-ucrt
|
|
110
|
+
sitearch = x64-ucrt
|
|
111
|
+
ruby_version = 3.2.0
|
|
112
112
|
ruby = $(bindir)/$(RUBY_BASE_NAME)
|
|
113
113
|
RUBY = $(ruby)
|
|
114
|
-
BUILTRUBY = $(bindir)/$(RUBY_BASE_NAME)
|
|
114
|
+
BUILTRUBY = $(bindir)/$(RUBY_BASE_NAME).exe
|
|
115
115
|
ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
|
|
116
116
|
|
|
117
117
|
RM = rm -f
|
|
118
118
|
RM_RF = rm -fr
|
|
119
|
-
RMDIRS = rmdir -p
|
|
120
|
-
MAKEDIRS = mkdir -p
|
|
119
|
+
RMDIRS = rmdir --ignore-fail-on-non-empty -p
|
|
120
|
+
MAKEDIRS = /usr/bin/mkdir -p
|
|
121
121
|
INSTALL = /usr/bin/install -c
|
|
122
122
|
INSTALL_PROG = $(INSTALL) -m 0755
|
|
123
123
|
INSTALL_DATA = $(INSTALL) -m 644
|
|
@@ -127,19 +127,19 @@ TOUCH = exit >
|
|
|
127
127
|
#### End of system configuration section. ####
|
|
128
128
|
|
|
129
129
|
preload =
|
|
130
|
-
libpath = . $(libdir) /
|
|
131
|
-
LIBPATH = -L. -L$(libdir) -
|
|
132
|
-
DEFFILE =
|
|
130
|
+
libpath = . $(libdir) C:\vcpkg\installed\x64-windows/lib C:/vcpkg/installed/x64-windows/lib
|
|
131
|
+
LIBPATH = -L. -L$(libdir) -LC:\vcpkg\installed\x64-windows/lib -LC:/vcpkg/installed/x64-windows/lib
|
|
132
|
+
DEFFILE = $(TARGET)-$(arch).def
|
|
133
133
|
|
|
134
|
-
CLEANFILES = mkmf.log
|
|
134
|
+
CLEANFILES = mkmf.log $(DEFFILE)
|
|
135
135
|
DISTCLEANFILES =
|
|
136
136
|
DISTCLEANDIRS =
|
|
137
137
|
|
|
138
138
|
extout =
|
|
139
139
|
extout_prefix =
|
|
140
140
|
target_prefix = /archive_r
|
|
141
|
-
LOCAL_LIBS = /
|
|
142
|
-
LIBS = $(LIBRUBYARG_SHARED) -larchive -
|
|
141
|
+
LOCAL_LIBS = "D:/a/archive_r/archive_r/build/Release/archive_r_core.lib"
|
|
142
|
+
LIBS = $(LIBRUBYARG_SHARED) -larchive -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi -lbcrypt
|
|
143
143
|
ORIG_SRCS = archive_r_ext.cc
|
|
144
144
|
SRCS = $(ORIG_SRCS)
|
|
145
145
|
OBJS = archive_r_ext.o
|
|
@@ -148,7 +148,7 @@ LOCAL_HDRS =
|
|
|
148
148
|
TARGET = archive_r
|
|
149
149
|
TARGET_NAME = archive_r
|
|
150
150
|
TARGET_ENTRY = Init_$(TARGET_NAME)
|
|
151
|
-
DLLIB = $(TARGET).
|
|
151
|
+
DLLIB = $(TARGET).so
|
|
152
152
|
EXTSTATIC =
|
|
153
153
|
STATIC_LIB =
|
|
154
154
|
|
|
@@ -161,7 +161,7 @@ HDRDIR = $(sitehdrdir)$(target_prefix)
|
|
|
161
161
|
ARCHHDRDIR = $(sitearchhdrdir)$(target_prefix)
|
|
162
162
|
TARGET_SO_DIR =
|
|
163
163
|
TARGET_SO = $(TARGET_SO_DIR)$(DLLIB)
|
|
164
|
-
CLEANLIBS = $(TARGET_SO)
|
|
164
|
+
CLEANLIBS = $(TARGET_SO) false
|
|
165
165
|
CLEANOBJS = $(OBJS) *.bak
|
|
166
166
|
TARGET_SO_DIR_TIMESTAMP = $(TIMESTAMP_DIR)/.sitearchdir.-.archive_r.time
|
|
167
167
|
|
|
@@ -259,12 +259,15 @@ site-install-rb: install-rb
|
|
|
259
259
|
$(ECHO) translating $(<)
|
|
260
260
|
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
|
|
261
261
|
|
|
262
|
-
$(TARGET_SO): $(OBJS) Makefile
|
|
262
|
+
$(TARGET_SO): $(DEFFILE) $(OBJS) Makefile
|
|
263
263
|
$(ECHO) linking shared-object archive_r/$(DLLIB)
|
|
264
264
|
-$(Q)$(RM) $(@)
|
|
265
265
|
$(Q) $(LDSHAREDXX) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
|
|
266
|
-
$(Q) $(POSTLINK)
|
|
267
266
|
|
|
268
267
|
|
|
269
268
|
|
|
269
|
+
$(DEFFILE):
|
|
270
|
+
$(ECHO) generating $(@)
|
|
271
|
+
$(Q) (echo EXPORTS && echo $(TARGET_ENTRY)) > $@
|
|
272
|
+
|
|
270
273
|
$(OBJS): $(HDRS) $(ruby_headers)
|