libarchive 0.1.1-mswin32 → 0.1.2-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING.libarchive +60 -60
- data/LICENSE.libbzip2 +42 -42
- data/README.txt +6 -6
- data/lib/i386-mswin32/rblibarchive.so +0 -0
- data/lib/libarchive.rb +1 -0
- data/lib/libarchive_ruby.rb +1 -0
- data/libarchive.c +1766 -1762
- metadata +25 -8
- data/lib/i386-mswin32/libarchive_ruby.so +0 -0
data/COPYING.libarchive
CHANGED
@@ -1,60 +1,60 @@
|
|
1
|
-
The libarchive distribution as a whole is Copyright by Tim Kientzle
|
2
|
-
and is subject to the copyright notice reproduced at the bottom of
|
3
|
-
this file.
|
4
|
-
|
5
|
-
Each individual file in this distribution should have a clear
|
6
|
-
copyright/licensing statement at the beginning of the file. If any do
|
7
|
-
not, please let me know and I will rectify it. The following is
|
8
|
-
intended to summarize the copyright status of the individual files;
|
9
|
-
the actual statements in the files are controlling.
|
10
|
-
|
11
|
-
* Except as listed below, all C sources (including .c and .h files)
|
12
|
-
and documentation files are subject to the copyright notice reproduced
|
13
|
-
at the bottom of this file.
|
14
|
-
|
15
|
-
* The following source files are also subject in whole or in part to
|
16
|
-
a 3-clause UC Regents copyright; please read the individual source
|
17
|
-
files for details:
|
18
|
-
libarchive/archive_entry.c
|
19
|
-
libarchive/archive_read_support_compression_compress.c
|
20
|
-
libarchive/archive_write_set_compression_compress.c
|
21
|
-
libarchive/mtree.5
|
22
|
-
tar/matching.c
|
23
|
-
|
24
|
-
* The following source files are in the public domain:
|
25
|
-
tar/getdate.y
|
26
|
-
|
27
|
-
* The build files---including Makefiles, configure scripts,
|
28
|
-
and auxiliary scripts used as part of the compile process---have
|
29
|
-
widely varying licensing terms. Please check individual files before
|
30
|
-
distributing them to see if those restrictions apply to you.
|
31
|
-
|
32
|
-
I intend for all new source code to use the license below and hope over
|
33
|
-
time to replace code with other licenses with new implementations that
|
34
|
-
do use the license below. The varying licensing of the build scripts
|
35
|
-
seems to be an unavoidable mess.
|
36
|
-
|
37
|
-
|
38
|
-
Copyright (c) 2003-2008 <author(s)>
|
39
|
-
All rights reserved.
|
40
|
-
|
41
|
-
Redistribution and use in source and binary forms, with or without
|
42
|
-
modification, are permitted provided that the following conditions
|
43
|
-
are met:
|
44
|
-
1. Redistributions of source code must retain the above copyright
|
45
|
-
notice, this list of conditions and the following disclaimer
|
46
|
-
in this position and unchanged.
|
47
|
-
2. Redistributions in binary form must reproduce the above copyright
|
48
|
-
notice, this list of conditions and the following disclaimer in the
|
49
|
-
documentation and/or other materials provided with the distribution.
|
50
|
-
|
51
|
-
THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
52
|
-
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
53
|
-
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
54
|
-
IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
55
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
56
|
-
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
57
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
58
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
59
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
60
|
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1
|
+
The libarchive distribution as a whole is Copyright by Tim Kientzle
|
2
|
+
and is subject to the copyright notice reproduced at the bottom of
|
3
|
+
this file.
|
4
|
+
|
5
|
+
Each individual file in this distribution should have a clear
|
6
|
+
copyright/licensing statement at the beginning of the file. If any do
|
7
|
+
not, please let me know and I will rectify it. The following is
|
8
|
+
intended to summarize the copyright status of the individual files;
|
9
|
+
the actual statements in the files are controlling.
|
10
|
+
|
11
|
+
* Except as listed below, all C sources (including .c and .h files)
|
12
|
+
and documentation files are subject to the copyright notice reproduced
|
13
|
+
at the bottom of this file.
|
14
|
+
|
15
|
+
* The following source files are also subject in whole or in part to
|
16
|
+
a 3-clause UC Regents copyright; please read the individual source
|
17
|
+
files for details:
|
18
|
+
libarchive/archive_entry.c
|
19
|
+
libarchive/archive_read_support_compression_compress.c
|
20
|
+
libarchive/archive_write_set_compression_compress.c
|
21
|
+
libarchive/mtree.5
|
22
|
+
tar/matching.c
|
23
|
+
|
24
|
+
* The following source files are in the public domain:
|
25
|
+
tar/getdate.y
|
26
|
+
|
27
|
+
* The build files---including Makefiles, configure scripts,
|
28
|
+
and auxiliary scripts used as part of the compile process---have
|
29
|
+
widely varying licensing terms. Please check individual files before
|
30
|
+
distributing them to see if those restrictions apply to you.
|
31
|
+
|
32
|
+
I intend for all new source code to use the license below and hope over
|
33
|
+
time to replace code with other licenses with new implementations that
|
34
|
+
do use the license below. The varying licensing of the build scripts
|
35
|
+
seems to be an unavoidable mess.
|
36
|
+
|
37
|
+
|
38
|
+
Copyright (c) 2003-2008 <author(s)>
|
39
|
+
All rights reserved.
|
40
|
+
|
41
|
+
Redistribution and use in source and binary forms, with or without
|
42
|
+
modification, are permitted provided that the following conditions
|
43
|
+
are met:
|
44
|
+
1. Redistributions of source code must retain the above copyright
|
45
|
+
notice, this list of conditions and the following disclaimer
|
46
|
+
in this position and unchanged.
|
47
|
+
2. Redistributions in binary form must reproduce the above copyright
|
48
|
+
notice, this list of conditions and the following disclaimer in the
|
49
|
+
documentation and/or other materials provided with the distribution.
|
50
|
+
|
51
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
52
|
+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
53
|
+
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
54
|
+
IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
55
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
56
|
+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
57
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
58
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
59
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
60
|
+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/LICENSE.libbzip2
CHANGED
@@ -1,42 +1,42 @@
|
|
1
|
-
|
2
|
-
--------------------------------------------------------------------------
|
3
|
-
|
4
|
-
This program, "bzip2", the associated library "libbzip2", and all
|
5
|
-
documentation, are copyright (C) 1996-2007 Julian R Seward. All
|
6
|
-
rights reserved.
|
7
|
-
|
8
|
-
Redistribution and use in source and binary forms, with or without
|
9
|
-
modification, are permitted provided that the following conditions
|
10
|
-
are met:
|
11
|
-
|
12
|
-
1. Redistributions of source code must retain the above copyright
|
13
|
-
notice, this list of conditions and the following disclaimer.
|
14
|
-
|
15
|
-
2. The origin of this software must not be misrepresented; you must
|
16
|
-
not claim that you wrote the original software. If you use this
|
17
|
-
software in a product, an acknowledgment in the product
|
18
|
-
documentation would be appreciated but is not required.
|
19
|
-
|
20
|
-
3. Altered source versions must be plainly marked as such, and must
|
21
|
-
not be misrepresented as being the original software.
|
22
|
-
|
23
|
-
4. The name of the author may not be used to endorse or promote
|
24
|
-
products derived from this software without specific prior written
|
25
|
-
permission.
|
26
|
-
|
27
|
-
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
28
|
-
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
29
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
30
|
-
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
31
|
-
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
32
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
33
|
-
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
34
|
-
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
35
|
-
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
36
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
37
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
38
|
-
|
39
|
-
Julian Seward, jseward@bzip.org
|
40
|
-
bzip2/libbzip2 version 1.0.5 of 10 December 2007
|
41
|
-
|
42
|
-
--------------------------------------------------------------------------
|
1
|
+
|
2
|
+
--------------------------------------------------------------------------
|
3
|
+
|
4
|
+
This program, "bzip2", the associated library "libbzip2", and all
|
5
|
+
documentation, are copyright (C) 1996-2007 Julian R Seward. All
|
6
|
+
rights reserved.
|
7
|
+
|
8
|
+
Redistribution and use in source and binary forms, with or without
|
9
|
+
modification, are permitted provided that the following conditions
|
10
|
+
are met:
|
11
|
+
|
12
|
+
1. Redistributions of source code must retain the above copyright
|
13
|
+
notice, this list of conditions and the following disclaimer.
|
14
|
+
|
15
|
+
2. The origin of this software must not be misrepresented; you must
|
16
|
+
not claim that you wrote the original software. If you use this
|
17
|
+
software in a product, an acknowledgment in the product
|
18
|
+
documentation would be appreciated but is not required.
|
19
|
+
|
20
|
+
3. Altered source versions must be plainly marked as such, and must
|
21
|
+
not be misrepresented as being the original software.
|
22
|
+
|
23
|
+
4. The name of the author may not be used to endorse or promote
|
24
|
+
products derived from this software without specific prior written
|
25
|
+
permission.
|
26
|
+
|
27
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
28
|
+
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
29
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
30
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
31
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
32
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
33
|
+
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
34
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
35
|
+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
36
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
37
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
38
|
+
|
39
|
+
Julian Seward, jseward@bzip.org
|
40
|
+
bzip2/libbzip2 version 1.0.5 of 10 December 2007
|
41
|
+
|
42
|
+
--------------------------------------------------------------------------
|
data/README.txt
CHANGED
@@ -47,7 +47,7 @@ http://rubyforge.org/projects/libarchive
|
|
47
47
|
|
48
48
|
== Source Code
|
49
49
|
|
50
|
-
|
50
|
+
https://github.com/winebarrel/Libarchive-Ruby
|
51
51
|
|
52
52
|
== Dependency
|
53
53
|
|
@@ -61,7 +61,7 @@ gem install libarchive
|
|
61
61
|
|
62
62
|
== Example
|
63
63
|
=== reading archive
|
64
|
-
require '
|
64
|
+
require 'libarchive'
|
65
65
|
|
66
66
|
Archive.read_open_filename('foo.tar.gz') do |ar|
|
67
67
|
while entry = ar.next_header
|
@@ -78,9 +78,9 @@ gem install libarchive
|
|
78
78
|
end
|
79
79
|
|
80
80
|
=== creating archive
|
81
|
-
require '
|
81
|
+
require 'libarchive'
|
82
82
|
|
83
|
-
Archive.write_open_filename('foo.tar.bz2', Archive::COMPRESSION_BZIP2, Archive::
|
83
|
+
Archive.write_open_filename('foo.tar.bz2', Archive::COMPRESSION_BZIP2, Archive::FORMAT_TAR) do |ar|
|
84
84
|
Dir.glob('*.c').each do |fn|
|
85
85
|
ar.new_entry do |entry|
|
86
86
|
entry.copy_stat(fn)
|
@@ -98,7 +98,7 @@ gem install libarchive
|
|
98
98
|
end
|
99
99
|
|
100
100
|
=== creating archive by extarnal program
|
101
|
-
require '
|
101
|
+
require 'libarchive'
|
102
102
|
|
103
103
|
Archive.write_open_filename('foo.tar.lzo', 'lzop', Archive::FORMAT_TAR_USTAR) do |ar|
|
104
104
|
...
|
@@ -135,7 +135,7 @@ gem install libarchive
|
|
135
135
|
Libarchive/Ruby(mswin32) contains Libarchive(2.6.0) and libbzip2(1.0.5).
|
136
136
|
|
137
137
|
* Libarchive
|
138
|
-
* http://
|
138
|
+
* http://code.google.com/p/libarchive/
|
139
139
|
* see {COPYING.libarchive}[link:files/COPYING_libarchive.html]
|
140
140
|
|
141
141
|
* libbzip2
|
Binary file
|
data/lib/libarchive.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rblibarchive'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'rblibarchive'
|
data/libarchive.c
CHANGED
@@ -1,1762 +1,1766 @@
|
|
1
|
-
#include "libarchive_internal.h"
|
2
|
-
|
3
|
-
VALUE rb_mArchive;
|
4
|
-
VALUE rb_eArchiveError;
|
5
|
-
|
6
|
-
/* */
|
7
|
-
VALUE rb_libarchive_s_version_number(VALUE self) {
|
8
|
-
#if ARCHIVE_VERSION >= 2005000
|
9
|
-
return INT2NUM(archive_version_number());
|
10
|
-
#else
|
11
|
-
return INT2NUM(archive_version_stamp());
|
12
|
-
#endif
|
13
|
-
}
|
14
|
-
|
15
|
-
/* */
|
16
|
-
VALUE rb_libarchive_s_version_string(VALUE self) {
|
17
|
-
#if ARCHIVE_VERSION_NUMBER >= 2005000
|
18
|
-
return rb_str_new2(archive_version_string());
|
19
|
-
#else
|
20
|
-
return rb_str_new2(archive_version());
|
21
|
-
#endif
|
22
|
-
}
|
23
|
-
|
24
|
-
void DLLEXPORT
|
25
|
-
rb_mArchive = rb_define_module("Archive");
|
26
|
-
rb_define_const(rb_mArchive, "VERSION", rb_str_new2(VERSION));
|
27
|
-
|
28
|
-
rb_define_const(rb_mArchive, "COMPRESSION_NONE", INT2NUM(ARCHIVE_COMPRESSION_NONE));
|
29
|
-
|
30
|
-
rb_define_const(rb_mArchive, "
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
rb_define_const(rb_mArchive, "
|
36
|
-
|
37
|
-
|
38
|
-
rb_define_const(rb_mArchive, "
|
39
|
-
rb_define_const(rb_mArchive, "
|
40
|
-
|
41
|
-
|
42
|
-
rb_define_const(rb_mArchive, "
|
43
|
-
rb_define_const(rb_mArchive, "
|
44
|
-
rb_define_const(rb_mArchive, "
|
45
|
-
rb_define_const(rb_mArchive, "
|
46
|
-
rb_define_const(rb_mArchive, "
|
47
|
-
rb_define_const(rb_mArchive, "
|
48
|
-
rb_define_const(rb_mArchive, "
|
49
|
-
rb_define_const(rb_mArchive, "
|
50
|
-
rb_define_const(rb_mArchive, "
|
51
|
-
rb_define_const(rb_mArchive, "
|
52
|
-
rb_define_const(rb_mArchive, "
|
53
|
-
rb_define_const(rb_mArchive, "
|
54
|
-
rb_define_const(rb_mArchive, "
|
55
|
-
rb_define_const(rb_mArchive, "
|
56
|
-
rb_define_const(rb_mArchive, "
|
57
|
-
rb_define_const(rb_mArchive, "
|
58
|
-
rb_define_const(rb_mArchive, "
|
59
|
-
rb_define_const(rb_mArchive, "
|
60
|
-
|
61
|
-
rb_define_const(rb_mArchive, "
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
rb_define_const(rb_mArchive, "
|
66
|
-
|
67
|
-
|
68
|
-
rb_define_const(rb_mArchive, "
|
69
|
-
rb_define_const(rb_mArchive, "
|
70
|
-
rb_define_const(rb_mArchive, "
|
71
|
-
rb_define_const(rb_mArchive, "
|
72
|
-
rb_define_const(rb_mArchive, "
|
73
|
-
rb_define_const(rb_mArchive, "
|
74
|
-
rb_define_const(rb_mArchive, "
|
75
|
-
rb_define_const(rb_mArchive, "
|
76
|
-
|
77
|
-
rb_define_const(rb_mArchive, "
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
static void
|
101
|
-
|
102
|
-
}
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
rb_define_method(rb_cArchiveReader, "
|
166
|
-
rb_define_method(rb_cArchiveWriter, "
|
167
|
-
rb_define_method(rb_cArchiveReader, "
|
168
|
-
rb_define_method(rb_cArchiveWriter, "
|
169
|
-
rb_define_method(rb_cArchiveReader, "
|
170
|
-
rb_define_method(rb_cArchiveWriter, "
|
171
|
-
rb_define_method(rb_cArchiveReader, "
|
172
|
-
rb_define_method(rb_cArchiveWriter, "
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
static
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
}
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
}
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
rb_define_method(rb_cArchiveEntry, "
|
1091
|
-
|
1092
|
-
rb_define_method(rb_cArchiveEntry, "
|
1093
|
-
rb_define_method(rb_cArchiveEntry, "
|
1094
|
-
rb_define_method(rb_cArchiveEntry, "
|
1095
|
-
rb_define_method(rb_cArchiveEntry, "
|
1096
|
-
rb_define_method(rb_cArchiveEntry, "
|
1097
|
-
rb_define_method(rb_cArchiveEntry, "
|
1098
|
-
rb_define_method(rb_cArchiveEntry, "
|
1099
|
-
rb_define_method(rb_cArchiveEntry, "
|
1100
|
-
rb_define_method(rb_cArchiveEntry, "
|
1101
|
-
rb_define_method(rb_cArchiveEntry, "
|
1102
|
-
rb_define_method(rb_cArchiveEntry, "
|
1103
|
-
rb_define_method(rb_cArchiveEntry, "
|
1104
|
-
rb_define_method(rb_cArchiveEntry, "
|
1105
|
-
rb_define_method(rb_cArchiveEntry, "
|
1106
|
-
rb_define_method(rb_cArchiveEntry, "
|
1107
|
-
rb_define_method(rb_cArchiveEntry, "
|
1108
|
-
rb_define_method(rb_cArchiveEntry, "
|
1109
|
-
rb_define_method(rb_cArchiveEntry, "
|
1110
|
-
rb_define_method(rb_cArchiveEntry, "
|
1111
|
-
rb_define_method(rb_cArchiveEntry, "
|
1112
|
-
rb_define_method(rb_cArchiveEntry, "
|
1113
|
-
rb_define_method(rb_cArchiveEntry, "
|
1114
|
-
rb_define_method(rb_cArchiveEntry, "
|
1115
|
-
rb_define_method(rb_cArchiveEntry, "
|
1116
|
-
rb_define_method(rb_cArchiveEntry, "
|
1117
|
-
rb_define_method(rb_cArchiveEntry, "
|
1118
|
-
rb_define_method(rb_cArchiveEntry, "
|
1119
|
-
rb_define_method(rb_cArchiveEntry, "
|
1120
|
-
rb_define_method(rb_cArchiveEntry, "
|
1121
|
-
rb_define_method(rb_cArchiveEntry, "
|
1122
|
-
rb_define_method(rb_cArchiveEntry, "
|
1123
|
-
|
1124
|
-
rb_define_method(rb_cArchiveEntry, "
|
1125
|
-
|
1126
|
-
rb_define_method(rb_cArchiveEntry, "
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
rb_define_method(rb_cArchiveEntry, "
|
1132
|
-
|
1133
|
-
rb_define_method(rb_cArchiveEntry, "
|
1134
|
-
|
1135
|
-
rb_define_method(rb_cArchiveEntry, "
|
1136
|
-
rb_define_method(rb_cArchiveEntry, "
|
1137
|
-
rb_define_method(rb_cArchiveEntry, "
|
1138
|
-
|
1139
|
-
rb_define_method(rb_cArchiveEntry, "
|
1140
|
-
rb_define_method(rb_cArchiveEntry, "
|
1141
|
-
rb_define_method(rb_cArchiveEntry, "
|
1142
|
-
rb_define_method(rb_cArchiveEntry, "
|
1143
|
-
rb_define_method(rb_cArchiveEntry, "
|
1144
|
-
rb_define_method(rb_cArchiveEntry, "
|
1145
|
-
rb_define_method(rb_cArchiveEntry, "
|
1146
|
-
rb_define_method(rb_cArchiveEntry, "
|
1147
|
-
rb_define_method(rb_cArchiveEntry, "
|
1148
|
-
rb_define_method(rb_cArchiveEntry, "
|
1149
|
-
rb_define_method(rb_cArchiveEntry, "
|
1150
|
-
rb_define_method(rb_cArchiveEntry, "
|
1151
|
-
rb_define_method(rb_cArchiveEntry, "
|
1152
|
-
rb_define_method(rb_cArchiveEntry, "
|
1153
|
-
rb_define_method(rb_cArchiveEntry, "
|
1154
|
-
rb_define_method(rb_cArchiveEntry, "
|
1155
|
-
rb_define_method(rb_cArchiveEntry, "
|
1156
|
-
rb_define_method(rb_cArchiveEntry, "
|
1157
|
-
rb_define_method(rb_cArchiveEntry, "
|
1158
|
-
rb_define_method(rb_cArchiveEntry, "
|
1159
|
-
rb_define_method(rb_cArchiveEntry, "
|
1160
|
-
rb_define_method(rb_cArchiveEntry, "
|
1161
|
-
rb_define_method(rb_cArchiveEntry, "
|
1162
|
-
rb_define_method(rb_cArchiveEntry, "
|
1163
|
-
rb_define_method(rb_cArchiveEntry, "
|
1164
|
-
rb_define_method(rb_cArchiveEntry, "
|
1165
|
-
rb_define_method(rb_cArchiveEntry, "
|
1166
|
-
rb_define_method(rb_cArchiveEntry, "
|
1167
|
-
rb_define_method(rb_cArchiveEntry, "
|
1168
|
-
rb_define_method(rb_cArchiveEntry, "
|
1169
|
-
rb_define_method(rb_cArchiveEntry, "
|
1170
|
-
rb_define_method(rb_cArchiveEntry, "
|
1171
|
-
|
1172
|
-
rb_define_method(rb_cArchiveEntry, "
|
1173
|
-
|
1174
|
-
rb_define_method(rb_cArchiveEntry, "
|
1175
|
-
|
1176
|
-
rb_define_method(rb_cArchiveEntry, "
|
1177
|
-
|
1178
|
-
rb_define_method(rb_cArchiveEntry, "
|
1179
|
-
|
1180
|
-
rb_define_method(rb_cArchiveEntry, "
|
1181
|
-
rb_define_method(rb_cArchiveEntry, "
|
1182
|
-
|
1183
|
-
|
1184
|
-
rb_define_method(rb_cArchiveEntry, "
|
1185
|
-
rb_define_method(rb_cArchiveEntry, "
|
1186
|
-
|
1187
|
-
rb_define_method(rb_cArchiveEntry, "
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
if (
|
1223
|
-
|
1224
|
-
}
|
1225
|
-
|
1226
|
-
|
1227
|
-
r =
|
1228
|
-
}
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
}
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
}
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
if (!NIL_P(
|
1306
|
-
|
1307
|
-
}
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
if (!NIL_P(
|
1333
|
-
|
1334
|
-
}
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
if (
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
if (
|
1413
|
-
|
1414
|
-
}
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
}
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
rb_define_method(rb_cArchiveReader, "
|
1515
|
-
rb_define_method(rb_cArchiveReader, "
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
if (
|
1551
|
-
|
1552
|
-
}
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
}
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
if (
|
1711
|
-
|
1712
|
-
}
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1
|
+
#include "libarchive_internal.h"
|
2
|
+
|
3
|
+
VALUE rb_mArchive;
|
4
|
+
VALUE rb_eArchiveError;
|
5
|
+
|
6
|
+
/* */
|
7
|
+
VALUE rb_libarchive_s_version_number(VALUE self) {
|
8
|
+
#if ARCHIVE_VERSION >= 2005000
|
9
|
+
return INT2NUM(archive_version_number());
|
10
|
+
#else
|
11
|
+
return INT2NUM(archive_version_stamp());
|
12
|
+
#endif
|
13
|
+
}
|
14
|
+
|
15
|
+
/* */
|
16
|
+
VALUE rb_libarchive_s_version_string(VALUE self) {
|
17
|
+
#if ARCHIVE_VERSION_NUMBER >= 2005000
|
18
|
+
return rb_str_new2(archive_version_string());
|
19
|
+
#else
|
20
|
+
return rb_str_new2(archive_version());
|
21
|
+
#endif
|
22
|
+
}
|
23
|
+
|
24
|
+
void DLLEXPORT Init_rblibarchive() {
|
25
|
+
rb_mArchive = rb_define_module("Archive");
|
26
|
+
rb_define_const(rb_mArchive, "VERSION", rb_str_new2(VERSION));
|
27
|
+
|
28
|
+
rb_define_const(rb_mArchive, "COMPRESSION_NONE", INT2NUM(ARCHIVE_COMPRESSION_NONE));
|
29
|
+
#ifdef HAVE_ZLIB_H
|
30
|
+
rb_define_const(rb_mArchive, "COMPRESSION_GZIP", INT2NUM(ARCHIVE_COMPRESSION_GZIP));
|
31
|
+
#endif
|
32
|
+
#ifdef HAVE_BZLIB_H
|
33
|
+
rb_define_const(rb_mArchive, "COMPRESSION_BZIP2", INT2NUM(ARCHIVE_COMPRESSION_BZIP2));
|
34
|
+
#endif
|
35
|
+
rb_define_const(rb_mArchive, "COMPRESSION_COMPRESS", INT2NUM(ARCHIVE_COMPRESSION_COMPRESS));
|
36
|
+
// XXX:
|
37
|
+
/*
|
38
|
+
rb_define_const(rb_mArchive, "COMPRESSION_PROGRAM", INT2NUM(ARCHIVE_COMPRESSION_PROGRAM));
|
39
|
+
rb_define_const(rb_mArchive, "COMPRESSION_LZMA", INT2NUM(ARCHIVE_COMPRESSION_LZMA));
|
40
|
+
*/
|
41
|
+
|
42
|
+
rb_define_const(rb_mArchive, "FORMAT_BASE_MASK", INT2NUM(ARCHIVE_FORMAT_BASE_MASK));
|
43
|
+
rb_define_const(rb_mArchive, "FORMAT_CPIO", INT2NUM(ARCHIVE_FORMAT_CPIO));
|
44
|
+
rb_define_const(rb_mArchive, "FORMAT_CPIO_POSIX", INT2NUM(ARCHIVE_FORMAT_CPIO_POSIX));
|
45
|
+
rb_define_const(rb_mArchive, "FORMAT_CPIO_BIN_LE", INT2NUM(ARCHIVE_FORMAT_CPIO_BIN_LE));
|
46
|
+
rb_define_const(rb_mArchive, "FORMAT_CPIO_BIN_BE", INT2NUM(ARCHIVE_FORMAT_CPIO_BIN_BE));
|
47
|
+
rb_define_const(rb_mArchive, "FORMAT_CPIO_SVR4_NOCRC", INT2NUM(ARCHIVE_FORMAT_CPIO_SVR4_NOCRC));
|
48
|
+
rb_define_const(rb_mArchive, "FORMAT_CPIO_SVR4_CRC", INT2NUM(ARCHIVE_FORMAT_CPIO_SVR4_CRC));
|
49
|
+
rb_define_const(rb_mArchive, "FORMAT_SHAR", INT2NUM(ARCHIVE_FORMAT_SHAR));
|
50
|
+
rb_define_const(rb_mArchive, "FORMAT_SHAR_BASE", INT2NUM(ARCHIVE_FORMAT_SHAR_BASE));
|
51
|
+
rb_define_const(rb_mArchive, "FORMAT_SHAR_DUMP", INT2NUM(ARCHIVE_FORMAT_SHAR_DUMP));
|
52
|
+
rb_define_const(rb_mArchive, "FORMAT_TAR", INT2NUM(ARCHIVE_FORMAT_TAR));
|
53
|
+
rb_define_const(rb_mArchive, "FORMAT_TAR_USTAR", INT2NUM(ARCHIVE_FORMAT_TAR_USTAR));
|
54
|
+
rb_define_const(rb_mArchive, "FORMAT_TAR_PAX_INTERCHANGE", INT2NUM(ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE));
|
55
|
+
rb_define_const(rb_mArchive, "FORMAT_TAR_PAX_RESTRICTED", INT2NUM(ARCHIVE_FORMAT_TAR_PAX_RESTRICTED));
|
56
|
+
rb_define_const(rb_mArchive, "FORMAT_TAR_GNUTAR", INT2NUM(ARCHIVE_FORMAT_TAR_GNUTAR));
|
57
|
+
rb_define_const(rb_mArchive, "FORMAT_ISO9660", INT2NUM(ARCHIVE_FORMAT_ISO9660));
|
58
|
+
rb_define_const(rb_mArchive, "FORMAT_ISO9660_ROCKRIDGE", INT2NUM(ARCHIVE_FORMAT_ISO9660_ROCKRIDGE));
|
59
|
+
rb_define_const(rb_mArchive, "FORMAT_ZIP", INT2NUM(ARCHIVE_FORMAT_ZIP));
|
60
|
+
rb_define_const(rb_mArchive, "FORMAT_EMPTY", INT2NUM(ARCHIVE_FORMAT_EMPTY));
|
61
|
+
rb_define_const(rb_mArchive, "FORMAT_AR", INT2NUM(ARCHIVE_FORMAT_AR));
|
62
|
+
rb_define_const(rb_mArchive, "FORMAT_AR_GNU", INT2NUM(ARCHIVE_FORMAT_AR_GNU));
|
63
|
+
rb_define_const(rb_mArchive, "FORMAT_AR_BSD", INT2NUM(ARCHIVE_FORMAT_AR_BSD));
|
64
|
+
#ifdef ARCHIVE_FORMAT_MTREE
|
65
|
+
rb_define_const(rb_mArchive, "FORMAT_MTREE", INT2NUM(ARCHIVE_FORMAT_MTREE));
|
66
|
+
#endif
|
67
|
+
|
68
|
+
rb_define_const(rb_mArchive, "EXTRACT_OWNER", INT2NUM(ARCHIVE_EXTRACT_OWNER));
|
69
|
+
rb_define_const(rb_mArchive, "EXTRACT_PERM", INT2NUM(ARCHIVE_EXTRACT_PERM));
|
70
|
+
rb_define_const(rb_mArchive, "EXTRACT_TIME", INT2NUM(ARCHIVE_EXTRACT_TIME));
|
71
|
+
rb_define_const(rb_mArchive, "EXTRACT_NO_OVERWRITE", INT2NUM(ARCHIVE_EXTRACT_NO_OVERWRITE));
|
72
|
+
rb_define_const(rb_mArchive, "EXTRACT_UNLINK", INT2NUM(ARCHIVE_EXTRACT_UNLINK));
|
73
|
+
rb_define_const(rb_mArchive, "EXTRACT_ACL", INT2NUM(ARCHIVE_EXTRACT_ACL));
|
74
|
+
rb_define_const(rb_mArchive, "EXTRACT_FFLAGS", INT2NUM(ARCHIVE_EXTRACT_FFLAGS));
|
75
|
+
rb_define_const(rb_mArchive, "EXTRACT_XATTR", INT2NUM(ARCHIVE_EXTRACT_XATTR));
|
76
|
+
rb_define_const(rb_mArchive, "EXTRACT_SECURE_SYMLINKS", INT2NUM(ARCHIVE_EXTRACT_SECURE_SYMLINKS));
|
77
|
+
rb_define_const(rb_mArchive, "EXTRACT_SECURE_NODOTDOT", INT2NUM(ARCHIVE_EXTRACT_SECURE_NODOTDOT));
|
78
|
+
rb_define_const(rb_mArchive, "EXTRACT_NO_AUTODIR", INT2NUM(ARCHIVE_EXTRACT_NO_AUTODIR));
|
79
|
+
rb_define_const(rb_mArchive, "EXTRACT_NO_OVERWRITE_NEWER", INT2NUM(ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER));
|
80
|
+
#ifdef ARCHIVE_EXTRACT_SPARSE
|
81
|
+
rb_define_const(rb_mArchive, "EXTRACT_SPARSE", INT2NUM(ARCHIVE_EXTRACT_SPARSE));
|
82
|
+
#endif
|
83
|
+
|
84
|
+
rb_define_module_function(rb_mArchive, "version_number", rb_libarchive_s_version_number, 0);
|
85
|
+
rb_define_module_function(rb_mArchive, "version_string", rb_libarchive_s_version_string, 0);
|
86
|
+
|
87
|
+
rb_eArchiveError = rb_define_class_under(rb_mArchive, "Error", rb_eStandardError);
|
88
|
+
|
89
|
+
Init_libarchive_reader();
|
90
|
+
Init_libarchive_writer();
|
91
|
+
Init_libarchive_archive();
|
92
|
+
Init_libarchive_entry();
|
93
|
+
}
|
94
|
+
#include "libarchive_internal.h"
|
95
|
+
|
96
|
+
extern VALUE rb_cArchiveReader;
|
97
|
+
extern VALUE rb_cArchiveWriter;
|
98
|
+
extern VALUE rb_eArchiveError;
|
99
|
+
|
100
|
+
static void rb_libarchive_archive_free(struct rb_libarchive_archive_container *p) {
|
101
|
+
xfree(p);
|
102
|
+
}
|
103
|
+
|
104
|
+
static void rb_libarchive_archive_mark(struct rb_libarchive_archive_container *p) {
|
105
|
+
rb_gc_mark(p->memory);
|
106
|
+
}
|
107
|
+
|
108
|
+
VALUE rb_libarchive_archive_alloc(VALUE klass) {
|
109
|
+
struct rb_libarchive_archive_container *p = ALLOC(struct rb_libarchive_archive_container);
|
110
|
+
p->ar = NULL;
|
111
|
+
p->eof = 0;
|
112
|
+
p->memory = Qnil;
|
113
|
+
return Data_Wrap_Struct(klass, rb_libarchive_archive_mark, rb_libarchive_archive_free, p);
|
114
|
+
}
|
115
|
+
|
116
|
+
/* */
|
117
|
+
static VALUE rb_libarchive_archive_position_compressed(VALUE self) {
|
118
|
+
struct rb_libarchive_archive_container *p;
|
119
|
+
Data_Get_Struct(self, struct rb_libarchive_archive_container, p);
|
120
|
+
Check_Archive(p);
|
121
|
+
return LONG2NUM(archive_position_compressed(p->ar));
|
122
|
+
}
|
123
|
+
|
124
|
+
/* */
|
125
|
+
static VALUE rb_libarchive_archive_position_uncompressed(VALUE self) {
|
126
|
+
struct rb_libarchive_archive_container *p;
|
127
|
+
Data_Get_Struct(self, struct rb_libarchive_archive_container, p);
|
128
|
+
Check_Archive(p);
|
129
|
+
return LONG2NUM(archive_position_uncompressed(p->ar));
|
130
|
+
}
|
131
|
+
|
132
|
+
/* */
|
133
|
+
static VALUE rb_libarchive_archive_compression_name(VALUE self) {
|
134
|
+
struct rb_libarchive_archive_container *p;
|
135
|
+
Data_Get_Struct(self, struct rb_libarchive_archive_container, p);
|
136
|
+
Check_Archive(p);
|
137
|
+
return rb_str_new2(archive_compression_name(p->ar));
|
138
|
+
}
|
139
|
+
|
140
|
+
/* */
|
141
|
+
static VALUE rb_libarchive_archive_compression(VALUE self) {
|
142
|
+
struct rb_libarchive_archive_container *p;
|
143
|
+
Data_Get_Struct(self, struct rb_libarchive_archive_container, p);
|
144
|
+
Check_Archive(p);
|
145
|
+
return INT2NUM(archive_compression(p->ar));
|
146
|
+
}
|
147
|
+
|
148
|
+
/* */
|
149
|
+
static VALUE rb_libarchive_archive_format_name(VALUE self) {
|
150
|
+
struct rb_libarchive_archive_container *p;
|
151
|
+
Data_Get_Struct(self, struct rb_libarchive_archive_container, p);
|
152
|
+
Check_Archive(p);
|
153
|
+
return rb_str_new2(archive_format_name(p->ar));
|
154
|
+
}
|
155
|
+
|
156
|
+
/* */
|
157
|
+
static VALUE rb_libarchive_archive_format(VALUE self) {
|
158
|
+
struct rb_libarchive_archive_container *p;
|
159
|
+
Data_Get_Struct(self, struct rb_libarchive_archive_container, p);
|
160
|
+
Check_Archive(p);
|
161
|
+
return NUM2INT(archive_format(p->ar));
|
162
|
+
}
|
163
|
+
|
164
|
+
void Init_libarchive_archive() {
|
165
|
+
rb_define_method(rb_cArchiveReader, "position_compressed", rb_libarchive_archive_position_compressed, 0);
|
166
|
+
rb_define_method(rb_cArchiveWriter, "position_compressed", rb_libarchive_archive_position_compressed, 0);
|
167
|
+
rb_define_method(rb_cArchiveReader, "position_uncompressed", rb_libarchive_archive_position_uncompressed, 0);
|
168
|
+
rb_define_method(rb_cArchiveWriter, "position_uncompressed", rb_libarchive_archive_position_uncompressed, 0);
|
169
|
+
rb_define_method(rb_cArchiveReader, "compression_name", rb_libarchive_archive_compression_name, 0);
|
170
|
+
rb_define_method(rb_cArchiveWriter, "compression_name", rb_libarchive_archive_compression_name, 0);
|
171
|
+
rb_define_method(rb_cArchiveReader, "compression", rb_libarchive_archive_compression, 0);
|
172
|
+
rb_define_method(rb_cArchiveWriter, "compression", rb_libarchive_archive_compression, 0);
|
173
|
+
rb_define_method(rb_cArchiveReader, "format_name", rb_libarchive_archive_format_name, 0);
|
174
|
+
rb_define_method(rb_cArchiveWriter, "format_name", rb_libarchive_archive_format_name, 0);
|
175
|
+
rb_define_method(rb_cArchiveReader, "format", rb_libarchive_archive_format, 0);
|
176
|
+
rb_define_method(rb_cArchiveWriter, "format", rb_libarchive_archive_format, 0);
|
177
|
+
}
|
178
|
+
#include "libarchive_internal.h"
|
179
|
+
|
180
|
+
extern VALUE rb_mArchive;
|
181
|
+
VALUE rb_cArchiveEntry;
|
182
|
+
extern VALUE rb_eArchiveError;
|
183
|
+
|
184
|
+
static void rb_libarchive_entry_free(struct rb_libarchive_entry_container *p) {
|
185
|
+
xfree(p);
|
186
|
+
}
|
187
|
+
|
188
|
+
static VALUE rb_libarchive_entry_alloc(VALUE klass) {
|
189
|
+
struct rb_libarchive_entry_container *p = ALLOC(struct rb_libarchive_entry_container);
|
190
|
+
p->ae = NULL;
|
191
|
+
p->must_close = 1;
|
192
|
+
return Data_Wrap_Struct(klass, 0, rb_libarchive_entry_free, p);
|
193
|
+
}
|
194
|
+
|
195
|
+
/* */
|
196
|
+
VALUE rb_libarchive_entry_close(VALUE self) {
|
197
|
+
struct rb_libarchive_entry_container *p;
|
198
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
199
|
+
Check_Entry(p);
|
200
|
+
|
201
|
+
if (!p->must_close) {
|
202
|
+
rb_raise(rb_eArchiveError, "Close entry failed: It is not necessary to close");
|
203
|
+
}
|
204
|
+
|
205
|
+
archive_entry_free(p->ae);
|
206
|
+
p->ae = NULL;
|
207
|
+
return Qnil;
|
208
|
+
}
|
209
|
+
|
210
|
+
VALUE rb_libarchive_entry_new(struct archive_entry *ae, int must_close) {
|
211
|
+
VALUE entry;
|
212
|
+
struct rb_libarchive_entry_container *p;
|
213
|
+
entry = rb_funcall(rb_cArchiveEntry, rb_intern("new"), 0);
|
214
|
+
Data_Get_Struct(entry, struct rb_libarchive_entry_container, p);
|
215
|
+
p->ae = ae;
|
216
|
+
p->must_close = must_close;
|
217
|
+
return entry;
|
218
|
+
}
|
219
|
+
|
220
|
+
/* */
|
221
|
+
static VALUE rb_libarchive_entry_atime(VALUE self) {
|
222
|
+
struct rb_libarchive_entry_container *p;
|
223
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
224
|
+
Check_Entry(p);
|
225
|
+
return LONG2TIME((long) archive_entry_atime(p->ae));
|
226
|
+
}
|
227
|
+
|
228
|
+
/* */
|
229
|
+
static VALUE rb_libarchive_entry_atime_nsec(VALUE self) {
|
230
|
+
struct rb_libarchive_entry_container *p;
|
231
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
232
|
+
Check_Entry(p);
|
233
|
+
return LONG2NUM(archive_entry_atime_nsec(p->ae));
|
234
|
+
}
|
235
|
+
|
236
|
+
/* */
|
237
|
+
static VALUE rb_libarchive_entry_atime_is_set(VALUE self) {
|
238
|
+
struct rb_libarchive_entry_container *p;
|
239
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
240
|
+
Check_Entry(p);
|
241
|
+
return archive_entry_atime_is_set(p->ae) ? Qtrue : Qfalse;
|
242
|
+
}
|
243
|
+
|
244
|
+
/* */
|
245
|
+
static VALUE rb_libarchive_entry_birthtime(VALUE self) {
|
246
|
+
struct rb_libarchive_entry_container *p;
|
247
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
248
|
+
Check_Entry(p);
|
249
|
+
return LONG2TIME((long) archive_entry_birthtime(p->ae));
|
250
|
+
}
|
251
|
+
|
252
|
+
/* */
|
253
|
+
static VALUE rb_libarchive_entry_birthtime_nsec(VALUE self) {
|
254
|
+
struct rb_libarchive_entry_container *p;
|
255
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
256
|
+
Check_Entry(p);
|
257
|
+
return LONG2NUM(archive_entry_birthtime_nsec(p->ae));
|
258
|
+
}
|
259
|
+
|
260
|
+
/* */
|
261
|
+
static VALUE rb_libarchive_entry_birthtime_is_set(VALUE self) {
|
262
|
+
struct rb_libarchive_entry_container *p;
|
263
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
264
|
+
Check_Entry(p);
|
265
|
+
return archive_entry_birthtime_is_set(p->ae) ? Qtrue : Qfalse;
|
266
|
+
}
|
267
|
+
|
268
|
+
/* */
|
269
|
+
static VALUE rb_libarchive_entry_ctime(VALUE self) {
|
270
|
+
struct rb_libarchive_entry_container *p;
|
271
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
272
|
+
Check_Entry(p);
|
273
|
+
return LONG2TIME((long) archive_entry_ctime(p->ae));
|
274
|
+
}
|
275
|
+
|
276
|
+
/* */
|
277
|
+
static VALUE rb_libarchive_entry_ctime_nsec(VALUE self) {
|
278
|
+
struct rb_libarchive_entry_container *p;
|
279
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
280
|
+
Check_Entry(p);
|
281
|
+
return LONG2NUM(archive_entry_ctime_nsec(p->ae));
|
282
|
+
}
|
283
|
+
|
284
|
+
/* */
|
285
|
+
static VALUE rb_libarchive_entry_ctime_is_set(VALUE self) {
|
286
|
+
struct rb_libarchive_entry_container *p;
|
287
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
288
|
+
Check_Entry(p);
|
289
|
+
return archive_entry_ctime_is_set(p->ae) ? Qtrue : Qfalse;
|
290
|
+
}
|
291
|
+
|
292
|
+
/* */
|
293
|
+
static VALUE rb_libarchive_entry_dev(VALUE self) {
|
294
|
+
struct rb_libarchive_entry_container *p;
|
295
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
296
|
+
Check_Entry(p);
|
297
|
+
return LONG2NUM(archive_entry_dev(p->ae));
|
298
|
+
}
|
299
|
+
|
300
|
+
/* */
|
301
|
+
static VALUE rb_libarchive_entry_devmajor(VALUE self) {
|
302
|
+
struct rb_libarchive_entry_container *p;
|
303
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
304
|
+
Check_Entry(p);
|
305
|
+
return LONG2NUM(archive_entry_devmajor(p->ae));
|
306
|
+
}
|
307
|
+
|
308
|
+
/* */
|
309
|
+
static VALUE rb_libarchive_entry_devminor(VALUE self) {
|
310
|
+
struct rb_libarchive_entry_container *p;
|
311
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
312
|
+
Check_Entry(p);
|
313
|
+
return LONG2NUM(archive_entry_devminor(p->ae));
|
314
|
+
}
|
315
|
+
|
316
|
+
/* */
|
317
|
+
static VALUE rb_libarchive_entry_filetype(VALUE self) {
|
318
|
+
struct rb_libarchive_entry_container *p;
|
319
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
320
|
+
Check_Entry(p);
|
321
|
+
return INT2NUM(archive_entry_filetype(p->ae));
|
322
|
+
}
|
323
|
+
|
324
|
+
/* */
|
325
|
+
static VALUE rb_libarchive_entry_is_directory(VALUE self) {
|
326
|
+
struct rb_libarchive_entry_container *p;
|
327
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
328
|
+
Check_Entry(p);
|
329
|
+
return S_ISDIR(archive_entry_filetype(p->ae)) ? Qtrue : Qfalse;
|
330
|
+
}
|
331
|
+
|
332
|
+
/* */
|
333
|
+
static VALUE rb_libarchive_entry_is_character_special(VALUE self) {
|
334
|
+
struct rb_libarchive_entry_container *p;
|
335
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
336
|
+
Check_Entry(p);
|
337
|
+
return S_ISCHR(archive_entry_filetype(p->ae)) ? Qtrue : Qfalse;
|
338
|
+
}
|
339
|
+
|
340
|
+
/* */
|
341
|
+
static VALUE rb_libarchive_entry_is_block_special(VALUE self) {
|
342
|
+
struct rb_libarchive_entry_container *p;
|
343
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
344
|
+
Check_Entry(p);
|
345
|
+
return S_ISBLK(archive_entry_filetype(p->ae)) ? Qtrue : Qfalse;
|
346
|
+
}
|
347
|
+
|
348
|
+
/* */
|
349
|
+
static VALUE rb_libarchive_entry_is_regular(VALUE self) {
|
350
|
+
struct rb_libarchive_entry_container *p;
|
351
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
352
|
+
Check_Entry(p);
|
353
|
+
return S_ISREG(archive_entry_filetype(p->ae)) ? Qtrue : Qfalse;
|
354
|
+
}
|
355
|
+
|
356
|
+
/* */
|
357
|
+
static VALUE rb_libarchive_entry_is_symbolic_link(VALUE self) {
|
358
|
+
struct rb_libarchive_entry_container *p;
|
359
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
360
|
+
Check_Entry(p);
|
361
|
+
return S_ISLNK(archive_entry_filetype(p->ae)) ? Qtrue : Qfalse;
|
362
|
+
}
|
363
|
+
|
364
|
+
/* */
|
365
|
+
static VALUE rb_libarchive_entry_is_socket(VALUE self) {
|
366
|
+
struct rb_libarchive_entry_container *p;
|
367
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
368
|
+
Check_Entry(p);
|
369
|
+
return S_ISSOCK(archive_entry_filetype(p->ae)) ? Qtrue : Qfalse;
|
370
|
+
}
|
371
|
+
|
372
|
+
/* */
|
373
|
+
static VALUE rb_libarchive_entry_is_fifo(VALUE self) {
|
374
|
+
struct rb_libarchive_entry_container *p;
|
375
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
376
|
+
Check_Entry(p);
|
377
|
+
return S_ISFIFO(archive_entry_filetype(p->ae)) ? Qtrue : Qfalse;
|
378
|
+
}
|
379
|
+
|
380
|
+
/* */
|
381
|
+
static VALUE rb_libarchive_entry_fflags(VALUE self) {
|
382
|
+
struct rb_libarchive_entry_container *p;
|
383
|
+
long set, clear;
|
384
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
385
|
+
Check_Entry(p);
|
386
|
+
archive_entry_fflags(p->ae, &set, &clear);
|
387
|
+
return rb_ary_new3(2, LONG2NUM(set), LONG2NUM(clear));
|
388
|
+
}
|
389
|
+
|
390
|
+
/* */
|
391
|
+
static VALUE rb_libarchive_entry_fflags_text(VALUE self) {
|
392
|
+
struct rb_libarchive_entry_container *p;
|
393
|
+
const char *fflags_text;
|
394
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
395
|
+
Check_Entry(p);
|
396
|
+
fflags_text = archive_entry_fflags_text(p->ae);
|
397
|
+
return (fflags_text != NULL) ? rb_str_new2(fflags_text) : Qnil;
|
398
|
+
}
|
399
|
+
|
400
|
+
/* */
|
401
|
+
static VALUE rb_libarchive_entry_gid(VALUE self) {
|
402
|
+
struct rb_libarchive_entry_container *p;
|
403
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
404
|
+
Check_Entry(p);
|
405
|
+
return LONG2NUM(archive_entry_gid(p->ae));
|
406
|
+
}
|
407
|
+
|
408
|
+
/* */
|
409
|
+
static VALUE rb_libarchive_entry_gname(VALUE self) {
|
410
|
+
struct rb_libarchive_entry_container *p;
|
411
|
+
const char *gname;
|
412
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
413
|
+
Check_Entry(p);
|
414
|
+
gname = archive_entry_gname(p->ae);
|
415
|
+
return (gname != NULL) ? rb_str_new2(gname) : Qnil;
|
416
|
+
}
|
417
|
+
|
418
|
+
/* */
|
419
|
+
static VALUE rb_libarchive_entry_hardlink(VALUE self) {
|
420
|
+
struct rb_libarchive_entry_container *p;
|
421
|
+
const char *hardlink;
|
422
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
423
|
+
Check_Entry(p);
|
424
|
+
hardlink = archive_entry_hardlink(p->ae);
|
425
|
+
return (hardlink != NULL) ? rb_str_new2(hardlink) : Qnil;
|
426
|
+
}
|
427
|
+
|
428
|
+
/* */
|
429
|
+
static VALUE rb_libarchive_entry_ino(VALUE self) {
|
430
|
+
struct rb_libarchive_entry_container *p;
|
431
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
432
|
+
return LONG2NUM(archive_entry_ino(p->ae));
|
433
|
+
}
|
434
|
+
|
435
|
+
/* */
|
436
|
+
static VALUE rb_libarchive_entry_mode(VALUE self) {
|
437
|
+
struct rb_libarchive_entry_container *p;
|
438
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
439
|
+
return LONG2NUM(archive_entry_mode(p->ae));
|
440
|
+
}
|
441
|
+
|
442
|
+
/* */
|
443
|
+
static VALUE rb_libarchive_entry_mtime(VALUE self) {
|
444
|
+
struct rb_libarchive_entry_container *p;
|
445
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
446
|
+
Check_Entry(p);
|
447
|
+
return LONG2TIME((long) archive_entry_mtime(p->ae));
|
448
|
+
}
|
449
|
+
|
450
|
+
/* */
|
451
|
+
static VALUE rb_libarchive_entry_mtime_nsec(VALUE self) {
|
452
|
+
struct rb_libarchive_entry_container *p;
|
453
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
454
|
+
Check_Entry(p);
|
455
|
+
return LONG2NUM(archive_entry_mtime_nsec(p->ae));
|
456
|
+
}
|
457
|
+
|
458
|
+
/* */
|
459
|
+
static VALUE rb_libarchive_entry_mtime_is_set(VALUE self) {
|
460
|
+
struct rb_libarchive_entry_container *p;
|
461
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
462
|
+
Check_Entry(p);
|
463
|
+
return archive_entry_mtime_is_set(p->ae) ? Qtrue : Qfalse;
|
464
|
+
}
|
465
|
+
|
466
|
+
/* */
|
467
|
+
static VALUE rb_libarchive_entry_nlink(VALUE self) {
|
468
|
+
struct rb_libarchive_entry_container *p;
|
469
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
470
|
+
Check_Entry(p);
|
471
|
+
return LONG2NUM(archive_entry_nlink(p->ae));
|
472
|
+
}
|
473
|
+
|
474
|
+
/* */
|
475
|
+
static VALUE rb_libarchive_entry_pathname(VALUE self) {
|
476
|
+
struct rb_libarchive_entry_container *p;
|
477
|
+
const char *pathname;
|
478
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
479
|
+
Check_Entry(p);
|
480
|
+
pathname = archive_entry_pathname(p->ae);
|
481
|
+
return (pathname != NULL) ? rb_str_new2(pathname) : Qnil;
|
482
|
+
}
|
483
|
+
|
484
|
+
/* */
|
485
|
+
static VALUE rb_libarchive_entry_rdev(VALUE self) {
|
486
|
+
struct rb_libarchive_entry_container *p;
|
487
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
488
|
+
Check_Entry(p);
|
489
|
+
return LONG2NUM(archive_entry_rdev(p->ae));
|
490
|
+
}
|
491
|
+
|
492
|
+
/* */
|
493
|
+
static VALUE rb_libarchive_entry_rdevmajor(VALUE self) {
|
494
|
+
struct rb_libarchive_entry_container *p;
|
495
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
496
|
+
Check_Entry(p);
|
497
|
+
return LONG2NUM(archive_entry_rdevmajor(p->ae));
|
498
|
+
}
|
499
|
+
|
500
|
+
/* */
|
501
|
+
static VALUE rb_libarchive_entry_rdevminor(VALUE self) {
|
502
|
+
struct rb_libarchive_entry_container *p;
|
503
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
504
|
+
Check_Entry(p);
|
505
|
+
return LONG2NUM(archive_entry_rdevminor(p->ae));
|
506
|
+
}
|
507
|
+
|
508
|
+
#if ARCHIVE_VERSION_NUMBER >= 2005003
|
509
|
+
/* */
|
510
|
+
static VALUE rb_libarchive_entry_sourcepath(VALUE self) {
|
511
|
+
struct rb_libarchive_entry_container *p;
|
512
|
+
const char *sourcepath;
|
513
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
514
|
+
Check_Entry(p);
|
515
|
+
sourcepath = archive_entry_sourcepath(p->ae);
|
516
|
+
return (sourcepath != NULL) ? rb_str_new2(sourcepath) : Qnil;
|
517
|
+
}
|
518
|
+
#endif
|
519
|
+
|
520
|
+
/* */
|
521
|
+
static VALUE rb_libarchive_entry_size(VALUE self) {
|
522
|
+
struct rb_libarchive_entry_container *p;
|
523
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
524
|
+
Check_Entry(p);
|
525
|
+
return LONG2NUM(archive_entry_size(p->ae));
|
526
|
+
}
|
527
|
+
|
528
|
+
/* */
|
529
|
+
static VALUE rb_libarchive_entry_size_is_set(VALUE self) {
|
530
|
+
struct rb_libarchive_entry_container *p;
|
531
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
532
|
+
Check_Entry(p);
|
533
|
+
return archive_entry_size_is_set(p->ae) ? Qtrue : Qfalse;
|
534
|
+
}
|
535
|
+
|
536
|
+
#if ARCHIVE_VERSION_NUMBER >= 2003002
|
537
|
+
/* */
|
538
|
+
static VALUE rb_libarchive_entry_strmode(VALUE self) {
|
539
|
+
struct rb_libarchive_entry_container *p;
|
540
|
+
const char *strmode;
|
541
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
542
|
+
Check_Entry(p);
|
543
|
+
strmode = archive_entry_strmode(p->ae);
|
544
|
+
return (strmode != NULL) ? rb_str_new2(strmode) : Qnil;
|
545
|
+
}
|
546
|
+
#endif
|
547
|
+
|
548
|
+
/* */
|
549
|
+
static VALUE rb_libarchive_entry_symlink(VALUE self) {
|
550
|
+
struct rb_libarchive_entry_container *p;
|
551
|
+
const char *symlink;
|
552
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
553
|
+
Check_Entry(p);
|
554
|
+
symlink = archive_entry_symlink(p->ae);
|
555
|
+
return (symlink != NULL) ? rb_str_new2(symlink) : Qnil;
|
556
|
+
}
|
557
|
+
|
558
|
+
/* */
|
559
|
+
static VALUE rb_libarchive_entry_uid(VALUE self) {
|
560
|
+
struct rb_libarchive_entry_container *p;
|
561
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
562
|
+
Check_Entry(p);
|
563
|
+
return LONG2NUM(archive_entry_uid(p->ae));
|
564
|
+
}
|
565
|
+
|
566
|
+
/* */
|
567
|
+
static VALUE rb_libarchive_entry_uname(VALUE self) {
|
568
|
+
struct rb_libarchive_entry_container *p;
|
569
|
+
const char *uname;
|
570
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
571
|
+
Check_Entry(p);
|
572
|
+
uname = archive_entry_uname(p->ae);
|
573
|
+
return (uname != NULL) ? rb_str_new2(uname) : Qnil;
|
574
|
+
}
|
575
|
+
|
576
|
+
/* */
|
577
|
+
static VALUE rb_libarchive_entry_set_atime(VALUE self, VALUE v_time) {
|
578
|
+
struct rb_libarchive_entry_container *p;
|
579
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
580
|
+
Check_Entry(p);
|
581
|
+
Check_Class(v_time, rb_cTime);
|
582
|
+
archive_entry_set_atime(p->ae, TIME2LONG(v_time), 0);
|
583
|
+
return Qnil;
|
584
|
+
}
|
585
|
+
|
586
|
+
/* */
|
587
|
+
static VALUE rb_libarchive_entry_set_atime2(VALUE self, VALUE v_time, VALUE v_ns) {
|
588
|
+
struct rb_libarchive_entry_container *p;
|
589
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
590
|
+
Check_Entry(p);
|
591
|
+
Check_Class(v_time, rb_cTime);
|
592
|
+
Check_Type(v_ns, T_FIXNUM);
|
593
|
+
archive_entry_set_atime(p->ae, TIME2LONG(v_time), NUM2LONG(v_ns));
|
594
|
+
return Qnil;
|
595
|
+
}
|
596
|
+
|
597
|
+
/* */
|
598
|
+
static VALUE rb_libarchive_entry_unset_atime(VALUE self) {
|
599
|
+
struct rb_libarchive_entry_container *p;
|
600
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
601
|
+
Check_Entry(p);
|
602
|
+
archive_entry_unset_atime(p->ae);
|
603
|
+
return Qnil;
|
604
|
+
}
|
605
|
+
|
606
|
+
/* */
|
607
|
+
static VALUE rb_libarchive_entry_set_birthtime(VALUE self, VALUE v_time) {
|
608
|
+
struct rb_libarchive_entry_container *p;
|
609
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
610
|
+
Check_Entry(p);
|
611
|
+
Check_Class(v_time, rb_cTime);
|
612
|
+
archive_entry_set_birthtime(p->ae, TIME2LONG(v_time), 0);
|
613
|
+
return Qnil;
|
614
|
+
}
|
615
|
+
|
616
|
+
/* */
|
617
|
+
static VALUE rb_libarchive_entry_set_birthtime2(VALUE self, VALUE v_time, VALUE v_ns) {
|
618
|
+
struct rb_libarchive_entry_container *p;
|
619
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
620
|
+
Check_Entry(p);
|
621
|
+
Check_Class(v_time, rb_cTime);
|
622
|
+
Check_Type(v_ns, T_FIXNUM);
|
623
|
+
archive_entry_set_birthtime(p->ae, TIME2LONG(v_time), NUM2LONG(v_ns));
|
624
|
+
return Qnil;
|
625
|
+
}
|
626
|
+
|
627
|
+
/* */
|
628
|
+
static VALUE rb_libarchive_entry_unset_birthtime(VALUE self) {
|
629
|
+
struct rb_libarchive_entry_container *p;
|
630
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
631
|
+
Check_Entry(p);
|
632
|
+
archive_entry_unset_birthtime(p->ae);
|
633
|
+
return Qnil;
|
634
|
+
}
|
635
|
+
|
636
|
+
/* */
|
637
|
+
static VALUE rb_libarchive_entry_set_ctime(VALUE self, VALUE v_time) {
|
638
|
+
struct rb_libarchive_entry_container *p;
|
639
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
640
|
+
Check_Entry(p);
|
641
|
+
Check_Class(v_time, rb_cTime);
|
642
|
+
archive_entry_set_ctime(p->ae, TIME2LONG(v_time), 0);
|
643
|
+
return Qnil;
|
644
|
+
}
|
645
|
+
|
646
|
+
/* */
|
647
|
+
static VALUE rb_libarchive_entry_set_ctime2(VALUE self, VALUE v_time, VALUE v_ns) {
|
648
|
+
struct rb_libarchive_entry_container *p;
|
649
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
650
|
+
Check_Entry(p);
|
651
|
+
Check_Class(v_time, rb_cTime);
|
652
|
+
Check_Type(v_ns, T_FIXNUM);
|
653
|
+
archive_entry_set_ctime(p->ae, TIME2LONG(v_time), NUM2LONG(v_ns));
|
654
|
+
return Qnil;
|
655
|
+
}
|
656
|
+
|
657
|
+
/* */
|
658
|
+
static VALUE rb_libarchive_entry_unset_ctime(VALUE self) {
|
659
|
+
struct rb_libarchive_entry_container *p;
|
660
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
661
|
+
Check_Entry(p);
|
662
|
+
archive_entry_unset_ctime(p->ae);
|
663
|
+
return Qnil;
|
664
|
+
}
|
665
|
+
|
666
|
+
/* */
|
667
|
+
static VALUE rb_libarchive_entry_set_dev(VALUE self, VALUE v_dev) {
|
668
|
+
struct rb_libarchive_entry_container *p;
|
669
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
670
|
+
Check_Entry(p);
|
671
|
+
Check_Type(v_dev, T_FIXNUM);
|
672
|
+
archive_entry_set_dev(p->ae, NUM2LONG(v_dev));
|
673
|
+
return Qnil;
|
674
|
+
}
|
675
|
+
|
676
|
+
/* */
|
677
|
+
static VALUE rb_libarchive_entry_set_devmajor(VALUE self, VALUE v_dev) {
|
678
|
+
struct rb_libarchive_entry_container *p;
|
679
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
680
|
+
Check_Entry(p);
|
681
|
+
Check_Type(v_dev, T_FIXNUM);
|
682
|
+
archive_entry_set_devmajor(p->ae, NUM2LONG(v_dev));
|
683
|
+
return Qnil;
|
684
|
+
}
|
685
|
+
|
686
|
+
/* */
|
687
|
+
static VALUE rb_libarchive_entry_set_devminor(VALUE self, VALUE v_dev) {
|
688
|
+
struct rb_libarchive_entry_container *p;
|
689
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
690
|
+
Check_Entry(p);
|
691
|
+
Check_Type(v_dev, T_FIXNUM);
|
692
|
+
archive_entry_set_devminor(p->ae, NUM2LONG(v_dev));
|
693
|
+
return Qnil;
|
694
|
+
}
|
695
|
+
|
696
|
+
/* */
|
697
|
+
static VALUE rb_libarchive_entry_set_filetype(VALUE self, VALUE v_type) {
|
698
|
+
struct rb_libarchive_entry_container *p;
|
699
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
700
|
+
Check_Entry(p);
|
701
|
+
Check_Type(v_type, T_FIXNUM);
|
702
|
+
archive_entry_set_filetype(p->ae, NUM2LONG(v_type));
|
703
|
+
return Qnil;
|
704
|
+
}
|
705
|
+
|
706
|
+
/* */
|
707
|
+
static VALUE rb_libarchive_entry_set_fflags(VALUE self, VALUE v_set, VALUE v_clear) {
|
708
|
+
struct rb_libarchive_entry_container *p;
|
709
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
710
|
+
Check_Entry(p);
|
711
|
+
Check_Type(v_set, T_FIXNUM);
|
712
|
+
Check_Type(v_clear, T_FIXNUM);
|
713
|
+
archive_entry_set_fflags(p->ae, (unsigned long) NUM2LONG(v_set), (unsigned long) NUM2LONG(v_clear));
|
714
|
+
return Qnil;
|
715
|
+
}
|
716
|
+
|
717
|
+
/* */
|
718
|
+
static VALUE rb_libarchive_entry_copy_fflags_text(VALUE self, VALUE v_fflags_text) {
|
719
|
+
struct rb_libarchive_entry_container *p;
|
720
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
721
|
+
Check_Entry(p);
|
722
|
+
Check_Type(v_fflags_text, T_STRING);
|
723
|
+
archive_entry_copy_fflags_text(p->ae, RSTRING_PTR(v_fflags_text));
|
724
|
+
return Qnil;
|
725
|
+
}
|
726
|
+
|
727
|
+
/* */
|
728
|
+
static VALUE rb_libarchive_entry_set_gid(VALUE self, VALUE v_gid) {
|
729
|
+
struct rb_libarchive_entry_container *p;
|
730
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
731
|
+
Check_Entry(p);
|
732
|
+
Check_Type(v_gid, T_FIXNUM);
|
733
|
+
archive_entry_set_gid(p->ae, NUM2INT(v_gid));
|
734
|
+
return Qnil;
|
735
|
+
}
|
736
|
+
|
737
|
+
/* */
|
738
|
+
static VALUE rb_libarchive_entry_set_gname(VALUE self, VALUE v_gname) {
|
739
|
+
struct rb_libarchive_entry_container *p;
|
740
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
741
|
+
Check_Entry(p);
|
742
|
+
Check_Type(v_gname, T_STRING);
|
743
|
+
archive_entry_set_gname(p->ae, RSTRING_PTR(v_gname));
|
744
|
+
return Qnil;
|
745
|
+
}
|
746
|
+
|
747
|
+
/* */
|
748
|
+
static VALUE rb_libarchive_entry_copy_gname(VALUE self, VALUE v_gname) {
|
749
|
+
struct rb_libarchive_entry_container *p;
|
750
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
751
|
+
Check_Entry(p);
|
752
|
+
Check_Type(v_gname, T_STRING);
|
753
|
+
archive_entry_copy_gname(p->ae, RSTRING_PTR(v_gname));
|
754
|
+
return Qnil;
|
755
|
+
}
|
756
|
+
|
757
|
+
/* */
|
758
|
+
static VALUE rb_libarchive_entry_set_hardlink(VALUE self, VALUE v_hardlink) {
|
759
|
+
struct rb_libarchive_entry_container *p;
|
760
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
761
|
+
Check_Entry(p);
|
762
|
+
Check_Type(v_hardlink, T_STRING);
|
763
|
+
archive_entry_set_hardlink(p->ae, RSTRING_PTR(v_hardlink));
|
764
|
+
return Qnil;
|
765
|
+
}
|
766
|
+
|
767
|
+
/* */
|
768
|
+
static VALUE rb_libarchive_entry_copy_hardlink(VALUE self, VALUE v_hardlink) {
|
769
|
+
struct rb_libarchive_entry_container *p;
|
770
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
771
|
+
Check_Entry(p);
|
772
|
+
Check_Type(v_hardlink, T_STRING);
|
773
|
+
archive_entry_copy_hardlink(p->ae, RSTRING_PTR(v_hardlink));
|
774
|
+
return Qnil;
|
775
|
+
}
|
776
|
+
|
777
|
+
/* */
|
778
|
+
static VALUE rb_libarchive_entry_set_ino(VALUE self, VALUE v_ino) {
|
779
|
+
struct rb_libarchive_entry_container *p;
|
780
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
781
|
+
Check_Entry(p);
|
782
|
+
Check_Type(v_ino, T_FIXNUM);
|
783
|
+
archive_entry_set_ino(p->ae, (unsigned long) NUM2LONG(v_ino));
|
784
|
+
return Qnil;
|
785
|
+
}
|
786
|
+
|
787
|
+
/* */
|
788
|
+
static VALUE rb_libarchive_entry_set_link(VALUE self, VALUE v_link) {
|
789
|
+
struct rb_libarchive_entry_container *p;
|
790
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
791
|
+
Check_Entry(p);
|
792
|
+
Check_Type(v_link, T_STRING);
|
793
|
+
archive_entry_set_link(p->ae, RSTRING_PTR(v_link));
|
794
|
+
return Qnil;
|
795
|
+
}
|
796
|
+
|
797
|
+
/* */
|
798
|
+
static VALUE rb_libarchive_entry_copy_link(VALUE self, VALUE v_link) {
|
799
|
+
struct rb_libarchive_entry_container *p;
|
800
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
801
|
+
Check_Entry(p);
|
802
|
+
Check_Type(v_link, T_STRING);
|
803
|
+
archive_entry_copy_link(p->ae, RSTRING_PTR(v_link));
|
804
|
+
return Qnil;
|
805
|
+
}
|
806
|
+
|
807
|
+
/* */
|
808
|
+
static VALUE rb_libarchive_entry_set_mode(VALUE self, VALUE v_mode) {
|
809
|
+
struct rb_libarchive_entry_container *p;
|
810
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
811
|
+
Check_Entry(p);
|
812
|
+
Check_Type(v_mode, T_FIXNUM);
|
813
|
+
archive_entry_set_mode(p->ae, NUM2INT(v_mode));
|
814
|
+
return Qnil;
|
815
|
+
}
|
816
|
+
|
817
|
+
/* */
|
818
|
+
static VALUE rb_libarchive_entry_set_mtime(VALUE self, VALUE v_time) {
|
819
|
+
struct rb_libarchive_entry_container *p;
|
820
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
821
|
+
Check_Entry(p);
|
822
|
+
Check_Class(v_time, rb_cTime);
|
823
|
+
archive_entry_set_mtime(p->ae, TIME2LONG(v_time), 0);
|
824
|
+
return Qnil;
|
825
|
+
}
|
826
|
+
|
827
|
+
/* */
|
828
|
+
static VALUE rb_libarchive_entry_set_mtime2(VALUE self, VALUE v_time, VALUE v_ns) {
|
829
|
+
struct rb_libarchive_entry_container *p;
|
830
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
831
|
+
Check_Entry(p);
|
832
|
+
Check_Class(v_time, rb_cTime);
|
833
|
+
Check_Type(v_ns, T_FIXNUM);
|
834
|
+
archive_entry_set_mtime(p->ae, TIME2LONG(v_time), NUM2LONG(v_ns));
|
835
|
+
return Qnil;
|
836
|
+
}
|
837
|
+
|
838
|
+
/* */
|
839
|
+
static VALUE rb_libarchive_entry_unset_mtime(VALUE self) {
|
840
|
+
struct rb_libarchive_entry_container *p;
|
841
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
842
|
+
Check_Entry(p);
|
843
|
+
archive_entry_unset_mtime(p->ae);
|
844
|
+
return Qnil;
|
845
|
+
}
|
846
|
+
|
847
|
+
/* */
|
848
|
+
static VALUE rb_libarchive_entry_set_nlink(VALUE self, VALUE v_nlink) {
|
849
|
+
struct rb_libarchive_entry_container *p;
|
850
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
851
|
+
Check_Entry(p);
|
852
|
+
Check_Type(v_nlink, T_FIXNUM);
|
853
|
+
archive_entry_set_nlink(p->ae, NUM2LONG(v_nlink));
|
854
|
+
return Qnil;
|
855
|
+
}
|
856
|
+
|
857
|
+
/* */
|
858
|
+
static VALUE rb_libarchive_entry_set_pathname(VALUE self, VALUE v_filename) {
|
859
|
+
struct rb_libarchive_entry_container *p;
|
860
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
861
|
+
Check_Entry(p);
|
862
|
+
Check_Type(v_filename, T_STRING);
|
863
|
+
archive_entry_set_pathname(p->ae, RSTRING_PTR(v_filename));
|
864
|
+
return Qnil;
|
865
|
+
}
|
866
|
+
|
867
|
+
/* */
|
868
|
+
static VALUE rb_libarchive_entry_copy_pathname(VALUE self, VALUE v_filename) {
|
869
|
+
struct rb_libarchive_entry_container *p;
|
870
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
871
|
+
Check_Entry(p);
|
872
|
+
Check_Type(v_filename, T_STRING);
|
873
|
+
archive_entry_copy_pathname(p->ae, RSTRING_PTR(v_filename));
|
874
|
+
return Qnil;
|
875
|
+
}
|
876
|
+
|
877
|
+
/* */
|
878
|
+
static VALUE rb_libarchive_entry_set_perm(VALUE self, VALUE v_perm) {
|
879
|
+
struct rb_libarchive_entry_container *p;
|
880
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
881
|
+
Check_Entry(p);
|
882
|
+
Check_Type(v_perm, T_FIXNUM);
|
883
|
+
archive_entry_set_perm(p->ae, NUM2INT(v_perm));
|
884
|
+
return Qnil;
|
885
|
+
}
|
886
|
+
|
887
|
+
/* */
|
888
|
+
static VALUE rb_libarchive_entry_set_rdev(VALUE self, VALUE v_rdev) {
|
889
|
+
struct rb_libarchive_entry_container *p;
|
890
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
891
|
+
Check_Entry(p);
|
892
|
+
Check_Type(v_rdev, T_FIXNUM);
|
893
|
+
archive_entry_set_rdev(p->ae, NUM2LONG(v_rdev));
|
894
|
+
return Qnil;
|
895
|
+
}
|
896
|
+
|
897
|
+
/* */
|
898
|
+
static VALUE rb_libarchive_entry_set_rdevmajor(VALUE self, VALUE v_rdev) {
|
899
|
+
struct rb_libarchive_entry_container *p;
|
900
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
901
|
+
Check_Entry(p);
|
902
|
+
Check_Type(v_rdev, T_FIXNUM);
|
903
|
+
archive_entry_set_rdevmajor(p->ae, NUM2LONG(v_rdev));
|
904
|
+
return Qnil;
|
905
|
+
}
|
906
|
+
|
907
|
+
/* */
|
908
|
+
static VALUE rb_libarchive_entry_set_rdevminor(VALUE self, VALUE v_rdev) {
|
909
|
+
struct rb_libarchive_entry_container *p;
|
910
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
911
|
+
Check_Entry(p);
|
912
|
+
Check_Type(v_rdev, T_FIXNUM);
|
913
|
+
archive_entry_set_rdevminor(p->ae, NUM2LONG(v_rdev));
|
914
|
+
return Qnil;
|
915
|
+
}
|
916
|
+
|
917
|
+
/* */
|
918
|
+
static VALUE rb_libarchive_entry_set_size(VALUE self, VALUE v_size) {
|
919
|
+
struct rb_libarchive_entry_container *p;
|
920
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
921
|
+
Check_Entry(p);
|
922
|
+
Check_Type(v_size, T_FIXNUM);
|
923
|
+
archive_entry_set_size(p->ae, NUM2LONG(v_size));
|
924
|
+
return Qnil;
|
925
|
+
}
|
926
|
+
|
927
|
+
/* */
|
928
|
+
static VALUE rb_libarchive_entry_unset_size(VALUE self) {
|
929
|
+
struct rb_libarchive_entry_container *p;
|
930
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
931
|
+
Check_Entry(p);
|
932
|
+
archive_entry_unset_size(p->ae);
|
933
|
+
return Qnil;
|
934
|
+
}
|
935
|
+
|
936
|
+
#if ARCHIVE_VERSION_NUMBER >= 2005003
|
937
|
+
/* */
|
938
|
+
static VALUE rb_libarchive_entry_copy_sourcepath(VALUE self, VALUE v_sourcepath) {
|
939
|
+
struct rb_libarchive_entry_container *p;
|
940
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
941
|
+
Check_Entry(p);
|
942
|
+
Check_Type(v_sourcepath, T_STRING);
|
943
|
+
archive_entry_copy_sourcepath(p->ae, RSTRING_PTR(v_sourcepath));
|
944
|
+
return Qnil;
|
945
|
+
}
|
946
|
+
#endif
|
947
|
+
|
948
|
+
/* */
|
949
|
+
static VALUE rb_libarchive_entry_set_symlink(VALUE self, VALUE v_symlink) {
|
950
|
+
struct rb_libarchive_entry_container *p;
|
951
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
952
|
+
Check_Entry(p);
|
953
|
+
Check_Type(v_symlink, T_STRING);
|
954
|
+
archive_entry_set_symlink(p->ae, RSTRING_PTR(v_symlink));
|
955
|
+
return Qnil;
|
956
|
+
}
|
957
|
+
|
958
|
+
/* */
|
959
|
+
static VALUE rb_libarchive_entry_copy_symlink(VALUE self, VALUE v_symlink) {
|
960
|
+
struct rb_libarchive_entry_container *p;
|
961
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
962
|
+
Check_Entry(p);
|
963
|
+
Check_Type(v_symlink, T_STRING);
|
964
|
+
archive_entry_copy_symlink(p->ae, RSTRING_PTR(v_symlink));
|
965
|
+
return Qnil;
|
966
|
+
}
|
967
|
+
|
968
|
+
/* */
|
969
|
+
static VALUE rb_libarchive_entry_set_uid(VALUE self, VALUE v_uid) {
|
970
|
+
struct rb_libarchive_entry_container *p;
|
971
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
972
|
+
Check_Entry(p);
|
973
|
+
Check_Type(v_uid, T_FIXNUM);
|
974
|
+
archive_entry_set_uid(p->ae, NUM2INT(v_uid));
|
975
|
+
return Qnil;
|
976
|
+
}
|
977
|
+
|
978
|
+
/* */
|
979
|
+
static VALUE rb_libarchive_entry_set_uname(VALUE self, VALUE v_uname) {
|
980
|
+
struct rb_libarchive_entry_container *p;
|
981
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
982
|
+
Check_Entry(p);
|
983
|
+
Check_Type(v_uname, T_STRING);
|
984
|
+
archive_entry_set_uname(p->ae, RSTRING_PTR(v_uname));
|
985
|
+
return Qnil;
|
986
|
+
}
|
987
|
+
|
988
|
+
/* */
|
989
|
+
static VALUE rb_libarchive_entry_copy_uname(VALUE self, VALUE v_uname) {
|
990
|
+
struct rb_libarchive_entry_container *p;
|
991
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
992
|
+
Check_Entry(p);
|
993
|
+
Check_Type(v_uname, T_STRING);
|
994
|
+
archive_entry_copy_uname(p->ae, RSTRING_PTR(v_uname));
|
995
|
+
return Qnil;
|
996
|
+
}
|
997
|
+
|
998
|
+
/* */
|
999
|
+
static VALUE rb_libarchive_entry_copy_stat(VALUE self, VALUE v_filename) {
|
1000
|
+
struct rb_libarchive_entry_container *p;
|
1001
|
+
const char *filename;
|
1002
|
+
struct stat s;
|
1003
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
1004
|
+
Check_Entry(p);
|
1005
|
+
Check_Type(v_filename, T_STRING);
|
1006
|
+
filename = RSTRING_PTR(v_filename);
|
1007
|
+
|
1008
|
+
if (stat(filename, &s) != 0) {
|
1009
|
+
rb_raise(rb_eArchiveError, "Copy stat failed: %", strerror(errno));
|
1010
|
+
}
|
1011
|
+
|
1012
|
+
archive_entry_copy_stat(p->ae, &s);
|
1013
|
+
return Qnil;
|
1014
|
+
}
|
1015
|
+
|
1016
|
+
/* */
|
1017
|
+
static VALUE rb_libarchive_entry_copy_lstat(VALUE self, VALUE v_filename) {
|
1018
|
+
struct rb_libarchive_entry_container *p;
|
1019
|
+
const char *filename;
|
1020
|
+
struct stat s;
|
1021
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
1022
|
+
Check_Entry(p);
|
1023
|
+
Check_Type(v_filename, T_STRING);
|
1024
|
+
filename = RSTRING_PTR(v_filename);
|
1025
|
+
|
1026
|
+
if (lstat(filename, &s) != 0) {
|
1027
|
+
rb_raise(rb_eArchiveError, "Copy stat failed: %", strerror(errno));
|
1028
|
+
}
|
1029
|
+
|
1030
|
+
archive_entry_copy_stat(p->ae, &s);
|
1031
|
+
return Qnil;
|
1032
|
+
}
|
1033
|
+
|
1034
|
+
/* */
|
1035
|
+
static VALUE rb_libarchive_entry_xattr_clear(VALUE self) {
|
1036
|
+
struct rb_libarchive_entry_container *p;
|
1037
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
1038
|
+
Check_Entry(p);
|
1039
|
+
archive_entry_xattr_clear(p->ae);
|
1040
|
+
return Qnil;
|
1041
|
+
}
|
1042
|
+
|
1043
|
+
/* */
|
1044
|
+
static VALUE rb_libarchive_entry_xattr_add_entry(VALUE self, VALUE v_name, VALUE v_value) {
|
1045
|
+
struct rb_libarchive_entry_container *p;
|
1046
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
1047
|
+
Check_Entry(p);
|
1048
|
+
Check_Type(v_name, T_STRING);
|
1049
|
+
Check_Type(v_value, T_STRING);
|
1050
|
+
archive_entry_xattr_add_entry(p->ae, RSTRING_PTR(v_name), RSTRING_PTR(v_value), RSTRING_LEN(v_value));
|
1051
|
+
return Qnil;
|
1052
|
+
}
|
1053
|
+
|
1054
|
+
/* */
|
1055
|
+
static VALUE rb_libarchive_entry_xattr_count(VALUE self) {
|
1056
|
+
struct rb_libarchive_entry_container *p;
|
1057
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
1058
|
+
Check_Entry(p);
|
1059
|
+
return INT2NUM(archive_entry_xattr_count(p->ae));
|
1060
|
+
}
|
1061
|
+
|
1062
|
+
/* */
|
1063
|
+
static VALUE rb_libarchive_entry_xattr_reset(VALUE self) {
|
1064
|
+
struct rb_libarchive_entry_container *p;
|
1065
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
1066
|
+
Check_Entry(p);
|
1067
|
+
return INT2NUM(archive_entry_xattr_reset(p->ae));
|
1068
|
+
}
|
1069
|
+
|
1070
|
+
/* */
|
1071
|
+
static VALUE rb_libarchive_entry_xattr_next(VALUE self) {
|
1072
|
+
struct rb_libarchive_entry_container *p;
|
1073
|
+
const char *name;
|
1074
|
+
const void *value;
|
1075
|
+
size_t size;
|
1076
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
1077
|
+
Check_Entry(p);
|
1078
|
+
|
1079
|
+
if (archive_entry_xattr_next(p->ae, &name, &value, &size) != ARCHIVE_OK) {
|
1080
|
+
return Qnil;
|
1081
|
+
} else {
|
1082
|
+
return rb_ary_new3(3, rb_str_new2(name), rb_str_new(value, size));
|
1083
|
+
}
|
1084
|
+
}
|
1085
|
+
|
1086
|
+
void Init_libarchive_entry() {
|
1087
|
+
rb_cArchiveEntry = rb_define_class_under(rb_mArchive, "Entry", rb_cObject);
|
1088
|
+
rb_define_alloc_func(rb_cArchiveEntry, rb_libarchive_entry_alloc);
|
1089
|
+
rb_funcall(rb_cArchiveEntry, rb_intern("private_class_method"), 1, ID2SYM(rb_intern("new")));
|
1090
|
+
rb_define_method(rb_cArchiveEntry, "close", rb_libarchive_entry_close, 0);
|
1091
|
+
|
1092
|
+
rb_define_method(rb_cArchiveEntry, "atime", rb_libarchive_entry_atime, 0);
|
1093
|
+
rb_define_method(rb_cArchiveEntry, "atime_nsec", rb_libarchive_entry_atime_nsec, 0);
|
1094
|
+
rb_define_method(rb_cArchiveEntry, "atime_is_set?", rb_libarchive_entry_atime_is_set, 0);
|
1095
|
+
rb_define_method(rb_cArchiveEntry, "birthtime", rb_libarchive_entry_birthtime, 0);
|
1096
|
+
rb_define_method(rb_cArchiveEntry, "birthtime_nsec", rb_libarchive_entry_birthtime_nsec, 0);
|
1097
|
+
rb_define_method(rb_cArchiveEntry, "birthtime_is_set?", rb_libarchive_entry_birthtime_is_set, 0);
|
1098
|
+
rb_define_method(rb_cArchiveEntry, "ctime", rb_libarchive_entry_ctime, 0);
|
1099
|
+
rb_define_method(rb_cArchiveEntry, "ctime_nsec", rb_libarchive_entry_ctime_nsec, 0);
|
1100
|
+
rb_define_method(rb_cArchiveEntry, "ctime_is_set?", rb_libarchive_entry_ctime_is_set, 0);
|
1101
|
+
rb_define_method(rb_cArchiveEntry, "dev", rb_libarchive_entry_dev, 0);
|
1102
|
+
rb_define_method(rb_cArchiveEntry, "devmajor", rb_libarchive_entry_devmajor, 0);
|
1103
|
+
rb_define_method(rb_cArchiveEntry, "devminor", rb_libarchive_entry_devminor, 0);
|
1104
|
+
rb_define_method(rb_cArchiveEntry, "filetype", rb_libarchive_entry_filetype, 0);
|
1105
|
+
rb_define_method(rb_cArchiveEntry, "directory?", rb_libarchive_entry_is_directory, 0);
|
1106
|
+
rb_define_method(rb_cArchiveEntry, "character_special?", rb_libarchive_entry_is_character_special, 0);
|
1107
|
+
rb_define_method(rb_cArchiveEntry, "block_special?", rb_libarchive_entry_is_block_special, 0);
|
1108
|
+
rb_define_method(rb_cArchiveEntry, "regular?", rb_libarchive_entry_is_regular, 0);
|
1109
|
+
rb_define_method(rb_cArchiveEntry, "symbolic_link?", rb_libarchive_entry_is_symbolic_link, 0);
|
1110
|
+
rb_define_method(rb_cArchiveEntry, "socket?", rb_libarchive_entry_is_socket, 0);
|
1111
|
+
rb_define_method(rb_cArchiveEntry, "fifo?", rb_libarchive_entry_is_fifo, 0);
|
1112
|
+
rb_define_method(rb_cArchiveEntry, "fflags", rb_libarchive_entry_fflags, 0);
|
1113
|
+
rb_define_method(rb_cArchiveEntry, "fflags_text", rb_libarchive_entry_fflags_text, 0);
|
1114
|
+
rb_define_method(rb_cArchiveEntry, "gid", rb_libarchive_entry_gid, 0);
|
1115
|
+
rb_define_method(rb_cArchiveEntry, "gname", rb_libarchive_entry_gname, 0);
|
1116
|
+
rb_define_method(rb_cArchiveEntry, "hardlink", rb_libarchive_entry_hardlink, 0);
|
1117
|
+
rb_define_method(rb_cArchiveEntry, "ino", rb_libarchive_entry_ino, 0);
|
1118
|
+
rb_define_method(rb_cArchiveEntry, "mode", rb_libarchive_entry_mode, 0);
|
1119
|
+
rb_define_method(rb_cArchiveEntry, "mtime", rb_libarchive_entry_mtime, 0);
|
1120
|
+
rb_define_method(rb_cArchiveEntry, "mtime_nsec", rb_libarchive_entry_mtime_nsec, 0);
|
1121
|
+
rb_define_method(rb_cArchiveEntry, "mtime_is_set?", rb_libarchive_entry_mtime_is_set, 0);
|
1122
|
+
rb_define_method(rb_cArchiveEntry, "nlink", rb_libarchive_entry_nlink, 0);
|
1123
|
+
rb_define_method(rb_cArchiveEntry, "pathname", rb_libarchive_entry_pathname, 0);
|
1124
|
+
rb_define_method(rb_cArchiveEntry, "rdev", rb_libarchive_entry_rdev, 0);
|
1125
|
+
rb_define_method(rb_cArchiveEntry, "rdevmajor", rb_libarchive_entry_rdevmajor, 0);
|
1126
|
+
rb_define_method(rb_cArchiveEntry, "rdevminor", rb_libarchive_entry_rdevminor, 0);
|
1127
|
+
#if ARCHIVE_VERSION_NUMBER >= 2005003
|
1128
|
+
rb_define_method(rb_cArchiveEntry, "sourcepath", rb_libarchive_entry_sourcepath, 0);
|
1129
|
+
#endif
|
1130
|
+
rb_define_method(rb_cArchiveEntry, "size", rb_libarchive_entry_size, 0);
|
1131
|
+
rb_define_method(rb_cArchiveEntry, "size_is_set?", rb_libarchive_entry_size_is_set, 0);
|
1132
|
+
#if ARCHIVE_VERSION_NUMBER >= 2003002
|
1133
|
+
rb_define_method(rb_cArchiveEntry, "strmode", rb_libarchive_entry_strmode, 0);
|
1134
|
+
#endif
|
1135
|
+
rb_define_method(rb_cArchiveEntry, "symlink", rb_libarchive_entry_symlink, 0);
|
1136
|
+
rb_define_method(rb_cArchiveEntry, "uid", rb_libarchive_entry_uid, 0);
|
1137
|
+
rb_define_method(rb_cArchiveEntry, "uname", rb_libarchive_entry_uname, 0);
|
1138
|
+
|
1139
|
+
rb_define_method(rb_cArchiveEntry, "atime=", rb_libarchive_entry_set_atime, 1);
|
1140
|
+
rb_define_method(rb_cArchiveEntry, "set_atime", rb_libarchive_entry_set_atime2, 2);
|
1141
|
+
rb_define_method(rb_cArchiveEntry, "unset_atime", rb_libarchive_entry_unset_atime, 0);
|
1142
|
+
rb_define_method(rb_cArchiveEntry, "birthtimee=", rb_libarchive_entry_set_birthtime, 1);
|
1143
|
+
rb_define_method(rb_cArchiveEntry, "set_birthtime", rb_libarchive_entry_set_birthtime2, 2);
|
1144
|
+
rb_define_method(rb_cArchiveEntry, "unset_birthtime", rb_libarchive_entry_unset_birthtime, 0);
|
1145
|
+
rb_define_method(rb_cArchiveEntry, "ctime=", rb_libarchive_entry_set_ctime, 1);
|
1146
|
+
rb_define_method(rb_cArchiveEntry, "set_ctime", rb_libarchive_entry_set_ctime2, 2);
|
1147
|
+
rb_define_method(rb_cArchiveEntry, "unset_ctime", rb_libarchive_entry_unset_ctime, 0);
|
1148
|
+
rb_define_method(rb_cArchiveEntry, "dev=", rb_libarchive_entry_set_dev, 1);
|
1149
|
+
rb_define_method(rb_cArchiveEntry, "devmajor=", rb_libarchive_entry_set_devmajor, 1);
|
1150
|
+
rb_define_method(rb_cArchiveEntry, "devminor=", rb_libarchive_entry_set_devminor, 1);
|
1151
|
+
rb_define_method(rb_cArchiveEntry, "filetype=", rb_libarchive_entry_set_filetype, 1);
|
1152
|
+
rb_define_method(rb_cArchiveEntry, "set_fflags", rb_libarchive_entry_set_fflags, 2);
|
1153
|
+
rb_define_method(rb_cArchiveEntry, "copy_fflags_text", rb_libarchive_entry_copy_fflags_text, 1);
|
1154
|
+
rb_define_method(rb_cArchiveEntry, "gid=", rb_libarchive_entry_set_gid, 1);
|
1155
|
+
rb_define_method(rb_cArchiveEntry, "gname=", rb_libarchive_entry_set_gname, 1);
|
1156
|
+
rb_define_method(rb_cArchiveEntry, "copy_gname", rb_libarchive_entry_copy_gname, 1);
|
1157
|
+
rb_define_method(rb_cArchiveEntry, "hardlink=", rb_libarchive_entry_set_hardlink, 1);
|
1158
|
+
rb_define_method(rb_cArchiveEntry, "copy_hardlink", rb_libarchive_entry_copy_hardlink, 1);
|
1159
|
+
rb_define_method(rb_cArchiveEntry, "ino=", rb_libarchive_entry_set_ino, 1);
|
1160
|
+
rb_define_method(rb_cArchiveEntry, "link=", rb_libarchive_entry_set_link, 1);
|
1161
|
+
rb_define_method(rb_cArchiveEntry, "copy_link", rb_libarchive_entry_copy_link, 1);
|
1162
|
+
rb_define_method(rb_cArchiveEntry, "mode=", rb_libarchive_entry_set_mode, 1);
|
1163
|
+
rb_define_method(rb_cArchiveEntry, "mtime=", rb_libarchive_entry_set_mtime, 1);
|
1164
|
+
rb_define_method(rb_cArchiveEntry, "set_mtime", rb_libarchive_entry_set_mtime2, 2);
|
1165
|
+
rb_define_method(rb_cArchiveEntry, "unset_mtime", rb_libarchive_entry_unset_mtime, 0);
|
1166
|
+
rb_define_method(rb_cArchiveEntry, "nlink=", rb_libarchive_entry_set_nlink, 1);
|
1167
|
+
rb_define_method(rb_cArchiveEntry, "pathname=", rb_libarchive_entry_set_pathname, 1);
|
1168
|
+
rb_define_method(rb_cArchiveEntry, "copy_pathname", rb_libarchive_entry_copy_pathname, 1);
|
1169
|
+
rb_define_method(rb_cArchiveEntry, "perm=", rb_libarchive_entry_set_perm, 1);
|
1170
|
+
rb_define_method(rb_cArchiveEntry, "rdev=", rb_libarchive_entry_set_rdev, 1);
|
1171
|
+
rb_define_method(rb_cArchiveEntry, "rdevmajor=", rb_libarchive_entry_set_rdevmajor, 1);
|
1172
|
+
rb_define_method(rb_cArchiveEntry, "rdevminor=", rb_libarchive_entry_set_rdevminor, 1);
|
1173
|
+
rb_define_method(rb_cArchiveEntry, "size=", rb_libarchive_entry_set_size, 1);
|
1174
|
+
rb_define_method(rb_cArchiveEntry, "unset_size", rb_libarchive_entry_unset_size, 0);
|
1175
|
+
#if ARCHIVE_VERSION_NUMBER >= 2005003
|
1176
|
+
rb_define_method(rb_cArchiveEntry, "copy_sourcepath", rb_libarchive_entry_copy_sourcepath, 1);
|
1177
|
+
#endif
|
1178
|
+
rb_define_method(rb_cArchiveEntry, "symlink=", rb_libarchive_entry_set_symlink, 1);
|
1179
|
+
rb_define_method(rb_cArchiveEntry, "copy_symlink", rb_libarchive_entry_copy_symlink, 1);
|
1180
|
+
rb_define_method(rb_cArchiveEntry, "uid=", rb_libarchive_entry_set_uid, 1);
|
1181
|
+
rb_define_method(rb_cArchiveEntry, "uname=", rb_libarchive_entry_set_uname, 1);
|
1182
|
+
rb_define_method(rb_cArchiveEntry, "copy_uname", rb_libarchive_entry_copy_uname, 1);
|
1183
|
+
|
1184
|
+
rb_define_method(rb_cArchiveEntry, "copy_stat", rb_libarchive_entry_copy_stat, 1);
|
1185
|
+
rb_define_method(rb_cArchiveEntry, "copy_lstat", rb_libarchive_entry_copy_lstat, 1);
|
1186
|
+
|
1187
|
+
rb_define_method(rb_cArchiveEntry, "xattr_clear", rb_libarchive_entry_xattr_clear, 0);
|
1188
|
+
rb_define_method(rb_cArchiveEntry, "xattr_add_entry", rb_libarchive_entry_xattr_add_entry, 2);
|
1189
|
+
rb_define_method(rb_cArchiveEntry, "xattr_count", rb_libarchive_entry_xattr_count, 0);
|
1190
|
+
rb_define_method(rb_cArchiveEntry, "xattr_reset", rb_libarchive_entry_xattr_reset, 0);
|
1191
|
+
rb_define_method(rb_cArchiveEntry, "xattr_next", rb_libarchive_entry_xattr_next, 0);
|
1192
|
+
}
|
1193
|
+
#include "libarchive_internal.h"
|
1194
|
+
|
1195
|
+
extern VALUE rb_mArchive;
|
1196
|
+
VALUE rb_cArchiveReader;
|
1197
|
+
extern VALUE rb_eArchiveError;
|
1198
|
+
extern VALUE rb_cArchiveEntry;
|
1199
|
+
|
1200
|
+
static void rb_libarchive_reader_close0(struct rb_libarchive_archive_container *p) {
|
1201
|
+
archive_read_close(p->ar);
|
1202
|
+
archive_read_finish(p->ar);
|
1203
|
+
p->ar = NULL;
|
1204
|
+
}
|
1205
|
+
|
1206
|
+
/* */
|
1207
|
+
static VALUE rb_libarchive_reader_close(VALUE self) {
|
1208
|
+
struct rb_libarchive_archive_container *p;
|
1209
|
+
Data_Get_Struct(self, struct rb_libarchive_archive_container, p);
|
1210
|
+
Check_Archive(p);
|
1211
|
+
rb_libarchive_reader_close0(p);
|
1212
|
+
return Qnil;
|
1213
|
+
}
|
1214
|
+
|
1215
|
+
static VALUE rb_libarchive_reader_s_open0(int (*archive_open)(struct rb_libarchive_archive_container *, void *), void *arg, int compression, int format, const char *cmd) {
|
1216
|
+
VALUE reader;
|
1217
|
+
struct rb_libarchive_archive_container *p;
|
1218
|
+
int r;
|
1219
|
+
reader = rb_funcall(rb_cArchiveReader, rb_intern("new"), 0);
|
1220
|
+
Data_Get_Struct(reader, struct rb_libarchive_archive_container, p);
|
1221
|
+
|
1222
|
+
if ((p->ar = archive_read_new()) == NULL) {
|
1223
|
+
rb_raise(rb_eArchiveError, "Open reader failed: %s", strerror(errno));
|
1224
|
+
}
|
1225
|
+
|
1226
|
+
if (cmd != NULL) {
|
1227
|
+
r = archive_read_support_compression_program(p->ar, cmd);
|
1228
|
+
} else if (compression != -1) {
|
1229
|
+
r = archive_read_support_compression(p->ar, compression);
|
1230
|
+
} else {
|
1231
|
+
r = archive_read_support_compression_all(p->ar);
|
1232
|
+
}
|
1233
|
+
|
1234
|
+
if (r != ARCHIVE_OK) {
|
1235
|
+
char error_string[BUFSIZ];
|
1236
|
+
archive_copy_error_string(p->ar, error_string, BUFSIZ);
|
1237
|
+
rb_libarchive_reader_close0(p);
|
1238
|
+
rb_raise(rb_eArchiveError, "Support compression failed: %s", error_string);
|
1239
|
+
}
|
1240
|
+
|
1241
|
+
if (format != -1) {
|
1242
|
+
r = archive_read_support_format(p->ar, format);
|
1243
|
+
} else {
|
1244
|
+
r = archive_read_support_format_all(p->ar);
|
1245
|
+
}
|
1246
|
+
|
1247
|
+
if (r != ARCHIVE_OK) {
|
1248
|
+
char error_string[BUFSIZ];
|
1249
|
+
archive_copy_error_string(p->ar, error_string, BUFSIZ);
|
1250
|
+
rb_libarchive_reader_close0(p);
|
1251
|
+
rb_raise(rb_eArchiveError, "Support format failed: %s", error_string);
|
1252
|
+
}
|
1253
|
+
|
1254
|
+
if (archive_open(p, arg) != ARCHIVE_OK) {
|
1255
|
+
char error_string[BUFSIZ];
|
1256
|
+
archive_copy_error_string(p->ar, error_string, BUFSIZ);
|
1257
|
+
rb_libarchive_reader_close0(p);
|
1258
|
+
rb_raise(rb_eArchiveError, "Open reader failed: %s", error_string);
|
1259
|
+
}
|
1260
|
+
|
1261
|
+
if (rb_block_given_p()) {
|
1262
|
+
VALUE retval;
|
1263
|
+
int status;
|
1264
|
+
retval = rb_protect(rb_yield, reader, &status);
|
1265
|
+
rb_libarchive_reader_close0(p);
|
1266
|
+
|
1267
|
+
if (status != 0) {
|
1268
|
+
rb_jump_tag(status);
|
1269
|
+
}
|
1270
|
+
|
1271
|
+
return retval;
|
1272
|
+
} else {
|
1273
|
+
return reader;
|
1274
|
+
}
|
1275
|
+
}
|
1276
|
+
|
1277
|
+
static int rb_libarchive_reader_s_open_filename0(struct rb_libarchive_archive_container *p, void *arg) {
|
1278
|
+
const char *filename = (const char *) arg;
|
1279
|
+
|
1280
|
+
if (filename != NULL) {
|
1281
|
+
struct stat s;
|
1282
|
+
|
1283
|
+
if (stat(filename, &s) != 0) {
|
1284
|
+
archive_set_error(p->ar, -1, strerror(errno));
|
1285
|
+
return (ARCHIVE_FATAL);
|
1286
|
+
}
|
1287
|
+
}
|
1288
|
+
|
1289
|
+
return archive_read_open_filename(p->ar, filename, BLOCK_SIZE);
|
1290
|
+
}
|
1291
|
+
|
1292
|
+
/* */
|
1293
|
+
static VALUE rb_libarchive_reader_s_open_filename(int argc, VALUE *argv, VALUE self) {
|
1294
|
+
VALUE v_filename, v_compression, v_format;
|
1295
|
+
const char *filename = NULL;
|
1296
|
+
int compression = -1, format = -1;
|
1297
|
+
const char *cmd = NULL;
|
1298
|
+
rb_scan_args(argc, argv, "12", &v_filename, &v_compression, &v_format);
|
1299
|
+
Check_Type(v_filename, T_STRING);
|
1300
|
+
filename = RSTRING_PTR(v_filename);
|
1301
|
+
|
1302
|
+
if (T_STRING == TYPE(v_compression)) {
|
1303
|
+
compression = -1;
|
1304
|
+
cmd = RSTRING_PTR(v_compression);
|
1305
|
+
} else if (!NIL_P(v_compression)) {
|
1306
|
+
compression = NUM2INT(v_compression);
|
1307
|
+
}
|
1308
|
+
|
1309
|
+
if (!NIL_P(v_format)) {
|
1310
|
+
format = NUM2INT(v_format);
|
1311
|
+
}
|
1312
|
+
|
1313
|
+
return rb_libarchive_reader_s_open0(rb_libarchive_reader_s_open_filename0, (void *) filename, compression, format, cmd);
|
1314
|
+
}
|
1315
|
+
|
1316
|
+
static int rb_libarchive_reader_s_open_memory0(struct rb_libarchive_archive_container *p, void *arg) {
|
1317
|
+
VALUE v_buff = (VALUE) arg;
|
1318
|
+
return archive_read_open_memory(p->ar, RSTRING_PTR(v_buff), RSTRING_LEN(v_buff));
|
1319
|
+
}
|
1320
|
+
|
1321
|
+
/* */
|
1322
|
+
static VALUE rb_libarchive_reader_s_open_memory(int argc, VALUE *argv, VALUE self) {
|
1323
|
+
VALUE v_memory, v_compression, v_format;
|
1324
|
+
int compression = -1, format = -1;
|
1325
|
+
const char *cmd = NULL;
|
1326
|
+
rb_scan_args(argc, argv, "12", &v_memory, &v_compression, &v_format);
|
1327
|
+
Check_Type(v_memory, T_STRING);
|
1328
|
+
|
1329
|
+
if (T_STRING == TYPE(v_compression)) {
|
1330
|
+
compression = -1;
|
1331
|
+
cmd = RSTRING_PTR(v_compression);
|
1332
|
+
} else if (!NIL_P(v_compression)) {
|
1333
|
+
compression = NUM2INT(v_compression);
|
1334
|
+
}
|
1335
|
+
|
1336
|
+
if (!NIL_P(v_format)) {
|
1337
|
+
format = NUM2INT(v_format);
|
1338
|
+
}
|
1339
|
+
|
1340
|
+
return rb_libarchive_reader_s_open0(rb_libarchive_reader_s_open_memory0, (void *) v_memory, compression, format, cmd);
|
1341
|
+
}
|
1342
|
+
|
1343
|
+
/* */
|
1344
|
+
static VALUE rb_libarchive_reader_next_header(VALUE self) {
|
1345
|
+
struct rb_libarchive_archive_container *p;
|
1346
|
+
struct archive_entry *ae;
|
1347
|
+
int r;
|
1348
|
+
Data_Get_Struct(self, struct rb_libarchive_archive_container, p);
|
1349
|
+
Check_Archive(p);
|
1350
|
+
|
1351
|
+
if (p->eof) {
|
1352
|
+
return Qnil;
|
1353
|
+
}
|
1354
|
+
|
1355
|
+
r = archive_read_next_header(p->ar, &ae);
|
1356
|
+
|
1357
|
+
if (r == ARCHIVE_EOF) {
|
1358
|
+
p->eof = 1;
|
1359
|
+
return Qnil;
|
1360
|
+
} else if (r != ARCHIVE_OK) {
|
1361
|
+
rb_raise(rb_eArchiveError, "Fetch entry failed: %s", archive_error_string(p->ar));
|
1362
|
+
}
|
1363
|
+
|
1364
|
+
return rb_libarchive_entry_new(ae, 0);
|
1365
|
+
}
|
1366
|
+
|
1367
|
+
/* */
|
1368
|
+
static VALUE rb_libarchive_reader_header_position(VALUE self) {
|
1369
|
+
struct rb_libarchive_archive_container *p;
|
1370
|
+
Data_Get_Struct(self, struct rb_libarchive_archive_container, p);
|
1371
|
+
Check_Archive(p);
|
1372
|
+
return LONG2NUM((long) archive_read_header_position(p->ar));
|
1373
|
+
}
|
1374
|
+
|
1375
|
+
/* */
|
1376
|
+
static VALUE rb_libarchive_reader_read_data(int argc, VALUE *argv, VALUE self) {
|
1377
|
+
VALUE v_size;
|
1378
|
+
struct rb_libarchive_archive_container *p;
|
1379
|
+
char *buff;
|
1380
|
+
size_t size = DATA_BUFFER_SIZE;
|
1381
|
+
ssize_t n;
|
1382
|
+
rb_scan_args(argc, argv, "01", &v_size);
|
1383
|
+
|
1384
|
+
if (!NIL_P(v_size)) {
|
1385
|
+
size = NUM2INT(v_size);
|
1386
|
+
}
|
1387
|
+
|
1388
|
+
Data_Get_Struct(self, struct rb_libarchive_archive_container, p);
|
1389
|
+
Check_Archive(p);
|
1390
|
+
|
1391
|
+
if (p->eof) {
|
1392
|
+
return Qnil;
|
1393
|
+
}
|
1394
|
+
|
1395
|
+
if (rb_block_given_p()) {
|
1396
|
+
ssize_t len = 0;
|
1397
|
+
int status = 0;
|
1398
|
+
buff = xmalloc(size);
|
1399
|
+
|
1400
|
+
while ((n = archive_read_data(p->ar, buff, size)) > 0) {
|
1401
|
+
rb_protect(rb_yield, rb_str_new(buff, n), &status);
|
1402
|
+
|
1403
|
+
if (status != 0) {
|
1404
|
+
break;
|
1405
|
+
}
|
1406
|
+
|
1407
|
+
len += n;
|
1408
|
+
}
|
1409
|
+
|
1410
|
+
xfree(buff);
|
1411
|
+
|
1412
|
+
if (status != 0) {
|
1413
|
+
rb_jump_tag(status);
|
1414
|
+
}
|
1415
|
+
|
1416
|
+
if (n < 0) {
|
1417
|
+
rb_raise(rb_eArchiveError, "Read data failed: %s", archive_error_string(p->ar));
|
1418
|
+
}
|
1419
|
+
|
1420
|
+
return LONG2NUM(len);
|
1421
|
+
} else {
|
1422
|
+
VALUE retval = rb_str_new("", 0);
|
1423
|
+
buff = xmalloc(size);
|
1424
|
+
|
1425
|
+
while ((n = archive_read_data(p->ar, buff, size)) > 0) {
|
1426
|
+
rb_str_cat(retval, buff, n);
|
1427
|
+
}
|
1428
|
+
|
1429
|
+
xfree(buff);
|
1430
|
+
|
1431
|
+
if (n < 0) {
|
1432
|
+
rb_raise(rb_eArchiveError, "Read data failed: %s", archive_error_string(p->ar));
|
1433
|
+
}
|
1434
|
+
|
1435
|
+
return retval;
|
1436
|
+
}
|
1437
|
+
}
|
1438
|
+
|
1439
|
+
/* */
|
1440
|
+
static VALUE rb_libarchive_reader_save_data(int argc, VALUE *argv, VALUE self) {
|
1441
|
+
VALUE v_filename, v_flags;
|
1442
|
+
struct rb_libarchive_archive_container *p;
|
1443
|
+
const char *filename;
|
1444
|
+
int flags, fd, r;
|
1445
|
+
rb_scan_args(argc, argv, "11", &v_filename, &v_flags);
|
1446
|
+
Check_Type(v_filename, T_STRING);
|
1447
|
+
filename = RSTRING_PTR(v_filename);
|
1448
|
+
|
1449
|
+
if (!NIL_P(v_flags)) {
|
1450
|
+
flags = ((O_WRONLY | NUM2INT(v_flags)) & O_FLAGS);
|
1451
|
+
} else {
|
1452
|
+
flags = (O_WRONLY | O_CREAT | O_EXCL
|
1453
|
+
#ifdef O_BINARY
|
1454
|
+
| O_BINARY
|
1455
|
+
#endif
|
1456
|
+
);
|
1457
|
+
}
|
1458
|
+
|
1459
|
+
Data_Get_Struct(self, struct rb_libarchive_archive_container, p);
|
1460
|
+
Check_Archive(p);
|
1461
|
+
|
1462
|
+
if ((fd = open(filename, flags)) == -1) {
|
1463
|
+
rb_raise(rb_eArchiveError, "Save data failed: %s", strerror(errno));
|
1464
|
+
}
|
1465
|
+
|
1466
|
+
r = archive_read_data_into_fd(p->ar, fd);
|
1467
|
+
_close(fd);
|
1468
|
+
|
1469
|
+
if (r != ARCHIVE_OK) {
|
1470
|
+
rb_raise(rb_eArchiveError, "Save data failed: %s", archive_error_string(p->ar));
|
1471
|
+
}
|
1472
|
+
|
1473
|
+
return Qnil;
|
1474
|
+
}
|
1475
|
+
|
1476
|
+
/* */
|
1477
|
+
static VALUE rb_libarchive_reader_extract(int argc, VALUE *argv, VALUE self) {
|
1478
|
+
VALUE v_entry, v_flags;
|
1479
|
+
struct rb_libarchive_archive_container *pa;
|
1480
|
+
struct rb_libarchive_entry_container *pae;
|
1481
|
+
int flags = 0;
|
1482
|
+
rb_scan_args(argc, argv, "11", &v_entry, &v_flags);
|
1483
|
+
Check_Class(v_entry, rb_cArchiveEntry);
|
1484
|
+
|
1485
|
+
if (!NIL_P(v_flags)) {
|
1486
|
+
flags = (NUM2INT(v_flags) & EXTRACT_FLAGS);
|
1487
|
+
}
|
1488
|
+
|
1489
|
+
Data_Get_Struct(self, struct rb_libarchive_archive_container, pa);
|
1490
|
+
Check_Archive(pa);
|
1491
|
+
|
1492
|
+
if (pa->eof) {
|
1493
|
+
rb_raise(rb_eArchiveError, "Extract archive failed: It has already reached EOF");
|
1494
|
+
}
|
1495
|
+
|
1496
|
+
Data_Get_Struct(v_entry, struct rb_libarchive_entry_container, pae);
|
1497
|
+
Check_Entry(pae);
|
1498
|
+
|
1499
|
+
if (archive_read_extract(pa->ar, pae->ae, flags) != ARCHIVE_OK) {
|
1500
|
+
rb_raise(rb_eArchiveError, "Extract archive failed: %s", archive_error_string(pa->ar));
|
1501
|
+
}
|
1502
|
+
|
1503
|
+
return Qnil;
|
1504
|
+
}
|
1505
|
+
|
1506
|
+
void Init_libarchive_reader() {
|
1507
|
+
rb_cArchiveReader = rb_define_class_under(rb_mArchive, "Reader", rb_cObject);
|
1508
|
+
rb_define_alloc_func(rb_cArchiveReader, rb_libarchive_archive_alloc);
|
1509
|
+
rb_funcall(rb_cArchiveReader, rb_intern("private_class_method"), 1, ID2SYM(rb_intern("new")));
|
1510
|
+
rb_define_singleton_method(rb_cArchiveReader, "open_filename", rb_libarchive_reader_s_open_filename, -1);
|
1511
|
+
rb_define_module_function(rb_mArchive, "read_open_filename", rb_libarchive_reader_s_open_filename, -1);
|
1512
|
+
rb_define_singleton_method(rb_cArchiveReader, "open_memory", rb_libarchive_reader_s_open_memory, -1);
|
1513
|
+
rb_define_module_function(rb_mArchive, "read_open_memory", rb_libarchive_reader_s_open_memory, -1);
|
1514
|
+
rb_define_method(rb_cArchiveReader, "close", rb_libarchive_reader_close, 0);
|
1515
|
+
rb_define_method(rb_cArchiveReader, "next_header", rb_libarchive_reader_next_header, 0);
|
1516
|
+
rb_define_method(rb_cArchiveReader, "header_position", rb_libarchive_reader_header_position, 0);
|
1517
|
+
rb_define_method(rb_cArchiveReader, "read_data", rb_libarchive_reader_read_data, -1);
|
1518
|
+
rb_define_method(rb_cArchiveReader, "save_data", rb_libarchive_reader_save_data, -1);
|
1519
|
+
rb_define_method(rb_cArchiveReader, "extract", rb_libarchive_reader_extract, -1);
|
1520
|
+
}
|
1521
|
+
#include "libarchive_internal.h"
|
1522
|
+
|
1523
|
+
extern VALUE rb_mArchive;
|
1524
|
+
VALUE rb_cArchiveWriter;
|
1525
|
+
extern VALUE rb_eArchiveError;
|
1526
|
+
extern VALUE rb_cArchiveEntry;
|
1527
|
+
|
1528
|
+
static void rb_libarchive_writer_close0(struct rb_libarchive_archive_container *p) {
|
1529
|
+
archive_write_close(p->ar);
|
1530
|
+
archive_write_finish(p->ar);
|
1531
|
+
p->ar = NULL;
|
1532
|
+
}
|
1533
|
+
|
1534
|
+
/* */
|
1535
|
+
static VALUE rb_libarchive_writer_close(VALUE self) {
|
1536
|
+
struct rb_libarchive_archive_container *p;
|
1537
|
+
Data_Get_Struct(self, struct rb_libarchive_archive_container, p);
|
1538
|
+
Check_Archive(p);
|
1539
|
+
rb_libarchive_writer_close0(p);
|
1540
|
+
return Qnil;
|
1541
|
+
}
|
1542
|
+
|
1543
|
+
static VALUE rb_libarchive_writer_s_open0(int (*archive_open)(struct rb_libarchive_archive_container *, void *), void *arg, int compression, int format, const char *cmd) {
|
1544
|
+
VALUE writer;
|
1545
|
+
struct rb_libarchive_archive_container *p;
|
1546
|
+
int r;
|
1547
|
+
writer = rb_funcall(rb_cArchiveWriter, rb_intern("new"), 0);
|
1548
|
+
Data_Get_Struct(writer, struct rb_libarchive_archive_container, p);
|
1549
|
+
|
1550
|
+
if ((p->ar = archive_write_new()) == NULL) {
|
1551
|
+
rb_raise(rb_eArchiveError, "Open writer failed: %s", strerror(errno));
|
1552
|
+
}
|
1553
|
+
|
1554
|
+
if (cmd != NULL) {
|
1555
|
+
r = archive_write_set_compression_program(p->ar, cmd);
|
1556
|
+
} else {
|
1557
|
+
r = archive_write_set_compression(p->ar, compression);
|
1558
|
+
}
|
1559
|
+
|
1560
|
+
if (r != ARCHIVE_OK) {
|
1561
|
+
char error_string[BUFSIZ];
|
1562
|
+
archive_copy_error_string(p->ar, error_string, BUFSIZ);
|
1563
|
+
rb_libarchive_writer_close0(p);
|
1564
|
+
rb_raise(rb_eArchiveError, "Set compression failed: %s", error_string);
|
1565
|
+
}
|
1566
|
+
|
1567
|
+
if (archive_write_set_format(p->ar, format) != ARCHIVE_OK) {
|
1568
|
+
char error_string[BUFSIZ];
|
1569
|
+
archive_copy_error_string(p->ar, error_string, BUFSIZ);
|
1570
|
+
rb_libarchive_writer_close0(p);
|
1571
|
+
rb_raise(rb_eArchiveError, "Set format failed: %s", error_string);
|
1572
|
+
}
|
1573
|
+
|
1574
|
+
if (archive_open(p, arg) != ARCHIVE_OK) {
|
1575
|
+
char error_string[BUFSIZ];
|
1576
|
+
archive_copy_error_string(p->ar, error_string, BUFSIZ);
|
1577
|
+
rb_libarchive_writer_close0(p);
|
1578
|
+
rb_raise(rb_eArchiveError, "Open writer failed: %s", error_string);
|
1579
|
+
}
|
1580
|
+
|
1581
|
+
if (rb_block_given_p()) {
|
1582
|
+
VALUE retval;
|
1583
|
+
int status;
|
1584
|
+
retval = rb_protect(rb_yield, writer, &status);
|
1585
|
+
rb_libarchive_writer_close0(p);
|
1586
|
+
|
1587
|
+
if (status != 0) {
|
1588
|
+
rb_jump_tag(status);
|
1589
|
+
}
|
1590
|
+
|
1591
|
+
return retval;
|
1592
|
+
} else {
|
1593
|
+
return writer;
|
1594
|
+
}
|
1595
|
+
}
|
1596
|
+
|
1597
|
+
static int rb_libarchive_writer_s_open_filename0(struct rb_libarchive_archive_container *p, void *arg) {
|
1598
|
+
const char *filename = (const char *) arg;
|
1599
|
+
return archive_write_open_filename(p->ar, filename);
|
1600
|
+
}
|
1601
|
+
|
1602
|
+
/* */
|
1603
|
+
static VALUE rb_libarchive_writer_s_open_filename(VALUE self, VALUE v_filename, VALUE v_compression, VALUE v_format) {
|
1604
|
+
const char *filename = NULL;
|
1605
|
+
int compression, format;
|
1606
|
+
const char *cmd = NULL;
|
1607
|
+
Check_Type(v_filename, T_STRING);
|
1608
|
+
|
1609
|
+
if (RSTRING_LEN(v_filename) < 1) {
|
1610
|
+
rb_raise(rb_eArchiveError, "Open writer failed: No such file or directory");
|
1611
|
+
}
|
1612
|
+
|
1613
|
+
filename = RSTRING_PTR(v_filename);
|
1614
|
+
|
1615
|
+
if (T_STRING == TYPE(v_compression)) {
|
1616
|
+
compression = -1;
|
1617
|
+
cmd = RSTRING_PTR(v_compression);
|
1618
|
+
} else {
|
1619
|
+
compression = NUM2INT(v_compression);
|
1620
|
+
}
|
1621
|
+
|
1622
|
+
|
1623
|
+
format = NUM2INT(v_format);
|
1624
|
+
return rb_libarchive_writer_s_open0(rb_libarchive_writer_s_open_filename0, (void *) filename, compression, format, cmd);
|
1625
|
+
}
|
1626
|
+
|
1627
|
+
static int rb_libarchive_writer_s_open_memory0(struct rb_libarchive_archive_container *p, void *arg) {
|
1628
|
+
VALUE str = (VALUE) arg;
|
1629
|
+
p->memory = str;
|
1630
|
+
return archive_write_open_rb_str(p->ar, str);
|
1631
|
+
}
|
1632
|
+
|
1633
|
+
/* */
|
1634
|
+
static VALUE rb_libarchive_writer_s_open_memory(VALUE self, VALUE v_memory, VALUE v_compression, VALUE v_format) {
|
1635
|
+
int compression, format;
|
1636
|
+
const char *cmd = NULL;
|
1637
|
+
Check_Type(v_memory, T_STRING);
|
1638
|
+
|
1639
|
+
if (T_STRING == TYPE(v_compression)) {
|
1640
|
+
compression = -1;
|
1641
|
+
cmd = RSTRING_PTR(v_compression);
|
1642
|
+
} else {
|
1643
|
+
compression = NUM2INT(v_compression);
|
1644
|
+
}
|
1645
|
+
|
1646
|
+
format = NUM2INT(v_format);
|
1647
|
+
return rb_libarchive_writer_s_open0(rb_libarchive_writer_s_open_memory0, (void *) v_memory, compression, format, cmd);
|
1648
|
+
}
|
1649
|
+
|
1650
|
+
/* */
|
1651
|
+
static VALUE rb_libarchive_writer_new_entry(VALUE self) {
|
1652
|
+
VALUE entry;
|
1653
|
+
struct rb_libarchive_archive_container *p;
|
1654
|
+
struct archive_entry *ae;
|
1655
|
+
Data_Get_Struct(self, struct rb_libarchive_archive_container, p);
|
1656
|
+
Check_Archive(p);
|
1657
|
+
|
1658
|
+
if ((ae = archive_entry_new()) == NULL) {
|
1659
|
+
rb_raise(rb_eArchiveError, "New entry failed: %s", strerror(errno));
|
1660
|
+
}
|
1661
|
+
|
1662
|
+
entry = rb_libarchive_entry_new(ae, 1);
|
1663
|
+
|
1664
|
+
if (rb_block_given_p()) {
|
1665
|
+
VALUE retval;
|
1666
|
+
int status;
|
1667
|
+
retval = rb_protect(rb_yield, entry, &status);
|
1668
|
+
rb_libarchive_entry_close(entry);
|
1669
|
+
|
1670
|
+
if (status != 0) {
|
1671
|
+
rb_jump_tag(status);
|
1672
|
+
}
|
1673
|
+
|
1674
|
+
return retval;
|
1675
|
+
} else {
|
1676
|
+
return entry;
|
1677
|
+
}
|
1678
|
+
}
|
1679
|
+
|
1680
|
+
/* */
|
1681
|
+
static VALUE rb_libarchive_writer_write_header(VALUE self, VALUE v_entry) {
|
1682
|
+
struct rb_libarchive_archive_container *pa;
|
1683
|
+
struct rb_libarchive_entry_container *pae;
|
1684
|
+
Check_Class(v_entry, rb_cArchiveEntry);
|
1685
|
+
Data_Get_Struct(self, struct rb_libarchive_archive_container, pa);
|
1686
|
+
Check_Archive(pa);
|
1687
|
+
Data_Get_Struct(v_entry, struct rb_libarchive_entry_container, pae);
|
1688
|
+
Check_Entry(pae);
|
1689
|
+
|
1690
|
+
if (archive_write_header(pa->ar, pae->ae) != ARCHIVE_OK) {
|
1691
|
+
rb_raise(rb_eArchiveError, "Write header failed: %s", archive_error_string(pa->ar));
|
1692
|
+
}
|
1693
|
+
|
1694
|
+
return Qnil;
|
1695
|
+
}
|
1696
|
+
|
1697
|
+
static ssize_t rb_libarchive_writer_write_data0(struct archive *ar, VALUE v_buff) {
|
1698
|
+
const char *buff;
|
1699
|
+
size_t size;
|
1700
|
+
ssize_t n;
|
1701
|
+
|
1702
|
+
if (NIL_P(v_buff)) {
|
1703
|
+
return 0;
|
1704
|
+
}
|
1705
|
+
|
1706
|
+
Check_Type(v_buff, T_STRING);
|
1707
|
+
buff = RSTRING_PTR(v_buff);
|
1708
|
+
size = RSTRING_LEN(v_buff);
|
1709
|
+
|
1710
|
+
if (size < 1) {
|
1711
|
+
return 0;
|
1712
|
+
}
|
1713
|
+
|
1714
|
+
if ((n = archive_write_data(ar, buff, size)) < 0) {
|
1715
|
+
rb_raise(rb_eArchiveError, "Write data failed: %s", archive_error_string(ar));
|
1716
|
+
}
|
1717
|
+
|
1718
|
+
return n;
|
1719
|
+
}
|
1720
|
+
|
1721
|
+
/* */
|
1722
|
+
static VALUE rb_libarchive_writer_write_data(int argc, VALUE *argv, VALUE self) {
|
1723
|
+
struct rb_libarchive_archive_container *p;
|
1724
|
+
Data_Get_Struct(self, struct rb_libarchive_archive_container, p);
|
1725
|
+
Check_Archive(p);
|
1726
|
+
|
1727
|
+
if (rb_block_given_p()) {
|
1728
|
+
ssize_t len = 0;
|
1729
|
+
|
1730
|
+
if (argc > 0) {
|
1731
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
|
1732
|
+
}
|
1733
|
+
|
1734
|
+
while(1) {
|
1735
|
+
VALUE retval;
|
1736
|
+
ssize_t n;
|
1737
|
+
retval = rb_yield(Qnil);
|
1738
|
+
|
1739
|
+
if ((n = rb_libarchive_writer_write_data0(p->ar, retval)) < 1) {
|
1740
|
+
return LONG2NUM(len);
|
1741
|
+
}
|
1742
|
+
|
1743
|
+
len += n;
|
1744
|
+
}
|
1745
|
+
} else {
|
1746
|
+
VALUE v_buff;
|
1747
|
+
ssize_t n;
|
1748
|
+
rb_scan_args(argc, argv, "10", &v_buff);
|
1749
|
+
n = rb_libarchive_writer_write_data0(p->ar, v_buff);
|
1750
|
+
return LONG2NUM(n);
|
1751
|
+
}
|
1752
|
+
}
|
1753
|
+
|
1754
|
+
void Init_libarchive_writer() {
|
1755
|
+
rb_cArchiveWriter = rb_define_class_under(rb_mArchive, "Writer", rb_cObject);
|
1756
|
+
rb_define_alloc_func(rb_cArchiveWriter, rb_libarchive_archive_alloc);
|
1757
|
+
rb_funcall(rb_cArchiveWriter, rb_intern("private_class_method"), 1, ID2SYM(rb_intern("new")));
|
1758
|
+
rb_define_singleton_method(rb_cArchiveWriter, "open_filename", rb_libarchive_writer_s_open_filename, 3);
|
1759
|
+
rb_define_singleton_method(rb_mArchive, "write_open_filename", rb_libarchive_writer_s_open_filename, 3);
|
1760
|
+
rb_define_singleton_method(rb_cArchiveWriter, "open_memory", rb_libarchive_writer_s_open_memory, 3);
|
1761
|
+
rb_define_singleton_method(rb_mArchive, "write_open_memory", rb_libarchive_writer_s_open_memory, 3);
|
1762
|
+
rb_define_method(rb_cArchiveWriter, "close", rb_libarchive_writer_close, 0);
|
1763
|
+
rb_define_method(rb_cArchiveWriter, "new_entry", rb_libarchive_writer_new_entry, 0);
|
1764
|
+
rb_define_method(rb_cArchiveWriter, "write_header", rb_libarchive_writer_write_header, 1);
|
1765
|
+
rb_define_method(rb_cArchiveWriter, "write_data", rb_libarchive_writer_write_data, -1);
|
1766
|
+
}
|