libarchive 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING.libarchive +60 -0
- data/LICENSE.libbzip2 +42 -0
- data/README.txt +17 -12
- data/ext/archive_read_support_format.c +1 -1
- data/ext/libarchive_internal.h +1 -1
- data/ext/libarchive_reader.c +18 -6
- data/ext/libarchive_writer.c +32 -6
- data/libarchive.c +50 -12
- metadata +6 -2
data/COPYING.libarchive
ADDED
@@ -0,0 +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.
|
data/LICENSE.libbzip2
ADDED
@@ -0,0 +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
|
+
--------------------------------------------------------------------------
|
data/README.txt
CHANGED
@@ -63,7 +63,7 @@ gem install libarchive
|
|
63
63
|
=== reading archive
|
64
64
|
require 'libarchive_ruby'
|
65
65
|
|
66
|
-
Archive
|
66
|
+
Archive.read_open_filename('foo.tar.gz') do |ar|
|
67
67
|
while entry = ar.next_header
|
68
68
|
name = entry.pathname
|
69
69
|
data = ar.read_data
|
@@ -79,9 +79,8 @@ gem install libarchive
|
|
79
79
|
|
80
80
|
=== creating archive
|
81
81
|
require 'libarchive_ruby'
|
82
|
-
include Archive
|
83
82
|
|
84
|
-
|
83
|
+
Archive.write_open_filename('foo.tar.bz2', Archive::COMPRESSION_BZIP2, Archive::FORMAT_TAR_USTAR) do |ar|
|
85
84
|
Dir.glob('*.c').each do |fn|
|
86
85
|
ar.new_entry do |entry|
|
87
86
|
entry.copy_stat(fn)
|
@@ -97,12 +96,12 @@ gem install libarchive
|
|
97
96
|
end
|
98
97
|
end
|
99
98
|
end
|
99
|
+
|
100
|
+
=== creating archive by extarnal program
|
101
|
+
require 'libarchive_ruby'
|
100
102
|
|
101
|
-
|
102
|
-
|
103
|
-
p entry.pathname
|
104
|
-
p ar.read_data.size
|
105
|
-
end
|
103
|
+
Archive.write_open_filename('foo.tar.lzo', 'lzop', Archive::FORMAT_TAR_USTAR) do |ar|
|
104
|
+
...
|
106
105
|
end
|
107
106
|
|
108
107
|
== License
|
@@ -132,7 +131,13 @@ gem install libarchive
|
|
132
131
|
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
133
132
|
DAMAGE.
|
134
133
|
|
135
|
-
===
|
136
|
-
Libarchive/Ruby(mswin32) contains Libarchive
|
137
|
-
|
138
|
-
*
|
134
|
+
=== Static link library
|
135
|
+
Libarchive/Ruby(mswin32) contains Libarchive(2.6.0) and libbzip2(1.0.5).
|
136
|
+
|
137
|
+
* Libarchive
|
138
|
+
* http://people.freebsd.org/~kientzle/libarchive/
|
139
|
+
* see {COPYING.libarchive}[link:files/COPYING_libarchive.html]
|
140
|
+
|
141
|
+
* libbzip2
|
142
|
+
* http://www.bzip.org/
|
143
|
+
* see {LICENSE.libbzip2}[link:files/LICENSE_libbzip2.html]
|
@@ -12,7 +12,7 @@ static struct {
|
|
12
12
|
{ ARCHIVE_FORMAT_ZIP, archive_read_support_format_zip },
|
13
13
|
{ ARCHIVE_FORMAT_EMPTY, archive_read_support_format_empty },
|
14
14
|
{ ARCHIVE_FORMAT_AR, archive_read_support_format_ar },
|
15
|
-
#
|
15
|
+
#ifdef ARCHIVE_FORMAT_MTREE
|
16
16
|
{ ARCHIVE_FORMAT_MTREE, archive_read_support_format_mtree },
|
17
17
|
#endif
|
18
18
|
{ -1, NULL },
|
data/ext/libarchive_internal.h
CHANGED
data/ext/libarchive_reader.c
CHANGED
@@ -20,7 +20,7 @@ static VALUE rb_libarchive_reader_close(VALUE self) {
|
|
20
20
|
return Qnil;
|
21
21
|
}
|
22
22
|
|
23
|
-
static VALUE rb_libarchive_reader_s_open0(int (*archive_open)(struct rb_libarchive_archive_container *, void *), void *arg, int compression, int format) {
|
23
|
+
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) {
|
24
24
|
VALUE reader;
|
25
25
|
struct rb_libarchive_archive_container *p;
|
26
26
|
int r;
|
@@ -31,7 +31,9 @@ static VALUE rb_libarchive_reader_s_open0(int (*archive_open)(struct rb_libarchi
|
|
31
31
|
rb_raise(rb_eArchiveError, "Open reader failed: %s", strerror(errno));
|
32
32
|
}
|
33
33
|
|
34
|
-
if (
|
34
|
+
if (cmd != NULL) {
|
35
|
+
r = archive_read_support_compression_program(p->ar, cmd);
|
36
|
+
} else if (compression != -1) {
|
35
37
|
r = archive_read_support_compression(p->ar, compression);
|
36
38
|
} else {
|
37
39
|
r = archive_read_support_compression_all(p->ar);
|
@@ -100,11 +102,15 @@ static VALUE rb_libarchive_reader_s_open_filename(int argc, VALUE *argv, VALUE s
|
|
100
102
|
VALUE v_filename, v_compression, v_format;
|
101
103
|
const char *filename = NULL;
|
102
104
|
int compression = -1, format = -1;
|
105
|
+
const char *cmd = NULL;
|
103
106
|
rb_scan_args(argc, argv, "12", &v_filename, &v_compression, &v_format);
|
104
107
|
Check_Type(v_filename, T_STRING);
|
105
108
|
filename = RSTRING_PTR(v_filename);
|
106
109
|
|
107
|
-
if (
|
110
|
+
if (T_STRING == TYPE(v_compression)) {
|
111
|
+
compression = -1;
|
112
|
+
cmd = RSTRING_PTR(v_compression);
|
113
|
+
} else if (!NIL_P(v_compression)) {
|
108
114
|
compression = NUM2INT(v_compression);
|
109
115
|
}
|
110
116
|
|
@@ -112,7 +118,7 @@ static VALUE rb_libarchive_reader_s_open_filename(int argc, VALUE *argv, VALUE s
|
|
112
118
|
format = NUM2INT(v_format);
|
113
119
|
}
|
114
120
|
|
115
|
-
return rb_libarchive_reader_s_open0(rb_libarchive_reader_s_open_filename0, (void *) filename, compression, format);
|
121
|
+
return rb_libarchive_reader_s_open0(rb_libarchive_reader_s_open_filename0, (void *) filename, compression, format, cmd);
|
116
122
|
}
|
117
123
|
|
118
124
|
static int rb_libarchive_reader_s_open_memory0(struct rb_libarchive_archive_container *p, void *arg) {
|
@@ -124,10 +130,14 @@ static int rb_libarchive_reader_s_open_memory0(struct rb_libarchive_archive_cont
|
|
124
130
|
static VALUE rb_libarchive_reader_s_open_memory(int argc, VALUE *argv, VALUE self) {
|
125
131
|
VALUE v_memory, v_compression, v_format;
|
126
132
|
int compression = -1, format = -1;
|
133
|
+
const char *cmd = NULL;
|
127
134
|
rb_scan_args(argc, argv, "12", &v_memory, &v_compression, &v_format);
|
128
135
|
Check_Type(v_memory, T_STRING);
|
129
136
|
|
130
|
-
if (
|
137
|
+
if (T_STRING == TYPE(v_compression)) {
|
138
|
+
compression = -1;
|
139
|
+
cmd = RSTRING_PTR(v_compression);
|
140
|
+
} else if (!NIL_P(v_compression)) {
|
131
141
|
compression = NUM2INT(v_compression);
|
132
142
|
}
|
133
143
|
|
@@ -135,7 +145,7 @@ static VALUE rb_libarchive_reader_s_open_memory(int argc, VALUE *argv, VALUE sel
|
|
135
145
|
format = NUM2INT(v_format);
|
136
146
|
}
|
137
147
|
|
138
|
-
return rb_libarchive_reader_s_open0(rb_libarchive_reader_s_open_memory0, (void *) v_memory, compression, format);
|
148
|
+
return rb_libarchive_reader_s_open0(rb_libarchive_reader_s_open_memory0, (void *) v_memory, compression, format, cmd);
|
139
149
|
}
|
140
150
|
|
141
151
|
/* */
|
@@ -306,7 +316,9 @@ void Init_libarchive_reader() {
|
|
306
316
|
rb_define_alloc_func(rb_cArchiveReader, rb_libarchive_archive_alloc);
|
307
317
|
rb_funcall(rb_cArchiveReader, rb_intern("private_class_method"), 1, ID2SYM(rb_intern("new")));
|
308
318
|
rb_define_singleton_method(rb_cArchiveReader, "open_filename", rb_libarchive_reader_s_open_filename, -1);
|
319
|
+
rb_define_module_function(rb_mArchive, "read_open_filename", rb_libarchive_reader_s_open_filename, -1);
|
309
320
|
rb_define_singleton_method(rb_cArchiveReader, "open_memory", rb_libarchive_reader_s_open_memory, -1);
|
321
|
+
rb_define_module_function(rb_mArchive, "read_open_memory", rb_libarchive_reader_s_open_memory, -1);
|
310
322
|
rb_define_method(rb_cArchiveReader, "close", rb_libarchive_reader_close, 0);
|
311
323
|
rb_define_method(rb_cArchiveReader, "next_header", rb_libarchive_reader_next_header, 0);
|
312
324
|
rb_define_method(rb_cArchiveReader, "header_position", rb_libarchive_reader_header_position, 0);
|
data/ext/libarchive_writer.c
CHANGED
@@ -20,9 +20,10 @@ static VALUE rb_libarchive_writer_close(VALUE self) {
|
|
20
20
|
return Qnil;
|
21
21
|
}
|
22
22
|
|
23
|
-
static VALUE rb_libarchive_writer_s_open0(int (*archive_open)(struct rb_libarchive_archive_container *, void *), void *arg, int compression, int format) {
|
23
|
+
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) {
|
24
24
|
VALUE writer;
|
25
25
|
struct rb_libarchive_archive_container *p;
|
26
|
+
int r;
|
26
27
|
writer = rb_funcall(rb_cArchiveWriter, rb_intern("new"), 0);
|
27
28
|
Data_Get_Struct(writer, struct rb_libarchive_archive_container, p);
|
28
29
|
|
@@ -30,7 +31,13 @@ static VALUE rb_libarchive_writer_s_open0(int (*archive_open)(struct rb_libarchi
|
|
30
31
|
rb_raise(rb_eArchiveError, "Open writer failed: %s", strerror(errno));
|
31
32
|
}
|
32
33
|
|
33
|
-
if (
|
34
|
+
if (cmd != NULL) {
|
35
|
+
r = archive_write_set_compression_program(p->ar, cmd);
|
36
|
+
} else {
|
37
|
+
r = archive_write_set_compression(p->ar, compression);
|
38
|
+
}
|
39
|
+
|
40
|
+
if (r != ARCHIVE_OK) {
|
34
41
|
char error_string[BUFSIZ];
|
35
42
|
archive_copy_error_string(p->ar, error_string, BUFSIZ);
|
36
43
|
rb_libarchive_writer_close0(p);
|
@@ -76,6 +83,7 @@ static int rb_libarchive_writer_s_open_filename0(struct rb_libarchive_archive_co
|
|
76
83
|
static VALUE rb_libarchive_writer_s_open_filename(VALUE self, VALUE v_filename, VALUE v_compression, VALUE v_format) {
|
77
84
|
const char *filename = NULL;
|
78
85
|
int compression, format;
|
86
|
+
const char *cmd = NULL;
|
79
87
|
Check_Type(v_filename, T_STRING);
|
80
88
|
|
81
89
|
if (RSTRING_LEN(v_filename) < 1) {
|
@@ -83,9 +91,17 @@ static VALUE rb_libarchive_writer_s_open_filename(VALUE self, VALUE v_filename,
|
|
83
91
|
}
|
84
92
|
|
85
93
|
filename = RSTRING_PTR(v_filename);
|
86
|
-
|
94
|
+
|
95
|
+
if (T_STRING == TYPE(v_compression)) {
|
96
|
+
compression = -1;
|
97
|
+
cmd = RSTRING_PTR(v_compression);
|
98
|
+
} else {
|
99
|
+
compression = NUM2INT(v_compression);
|
100
|
+
}
|
101
|
+
|
102
|
+
|
87
103
|
format = NUM2INT(v_format);
|
88
|
-
return rb_libarchive_writer_s_open0(rb_libarchive_writer_s_open_filename0, (void *) filename, compression, format);
|
104
|
+
return rb_libarchive_writer_s_open0(rb_libarchive_writer_s_open_filename0, (void *) filename, compression, format, cmd);
|
89
105
|
}
|
90
106
|
|
91
107
|
static int rb_libarchive_writer_s_open_memory0(struct rb_libarchive_archive_container *p, void *arg) {
|
@@ -97,10 +113,18 @@ static int rb_libarchive_writer_s_open_memory0(struct rb_libarchive_archive_cont
|
|
97
113
|
/* */
|
98
114
|
static VALUE rb_libarchive_writer_s_open_memory(VALUE self, VALUE v_memory, VALUE v_compression, VALUE v_format) {
|
99
115
|
int compression, format;
|
116
|
+
const char *cmd = NULL;
|
100
117
|
Check_Type(v_memory, T_STRING);
|
101
|
-
|
118
|
+
|
119
|
+
if (T_STRING == TYPE(v_compression)) {
|
120
|
+
compression = -1;
|
121
|
+
cmd = RSTRING_PTR(v_compression);
|
122
|
+
} else {
|
123
|
+
compression = NUM2INT(v_compression);
|
124
|
+
}
|
125
|
+
|
102
126
|
format = NUM2INT(v_format);
|
103
|
-
return rb_libarchive_writer_s_open0(rb_libarchive_writer_s_open_memory0, (void *) v_memory, compression, format);
|
127
|
+
return rb_libarchive_writer_s_open0(rb_libarchive_writer_s_open_memory0, (void *) v_memory, compression, format, cmd);
|
104
128
|
}
|
105
129
|
|
106
130
|
/* */
|
@@ -212,7 +236,9 @@ void Init_libarchive_writer() {
|
|
212
236
|
rb_define_alloc_func(rb_cArchiveWriter, rb_libarchive_archive_alloc);
|
213
237
|
rb_funcall(rb_cArchiveWriter, rb_intern("private_class_method"), 1, ID2SYM(rb_intern("new")));
|
214
238
|
rb_define_singleton_method(rb_cArchiveWriter, "open_filename", rb_libarchive_writer_s_open_filename, 3);
|
239
|
+
rb_define_singleton_method(rb_mArchive, "write_open_filename", rb_libarchive_writer_s_open_filename, 3);
|
215
240
|
rb_define_singleton_method(rb_cArchiveWriter, "open_memory", rb_libarchive_writer_s_open_memory, 3);
|
241
|
+
rb_define_singleton_method(rb_mArchive, "write_open_memory", rb_libarchive_writer_s_open_memory, 3);
|
216
242
|
rb_define_method(rb_cArchiveWriter, "close", rb_libarchive_writer_close, 0);
|
217
243
|
rb_define_method(rb_cArchiveWriter, "new_entry", rb_libarchive_writer_new_entry, 0);
|
218
244
|
rb_define_method(rb_cArchiveWriter, "write_header", rb_libarchive_writer_write_header, 1);
|
data/libarchive.c
CHANGED
@@ -1208,7 +1208,7 @@ static VALUE rb_libarchive_reader_close(VALUE self) {
|
|
1208
1208
|
return Qnil;
|
1209
1209
|
}
|
1210
1210
|
|
1211
|
-
static VALUE rb_libarchive_reader_s_open0(int (*archive_open)(struct rb_libarchive_archive_container *, void *), void *arg, int compression, int format) {
|
1211
|
+
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) {
|
1212
1212
|
VALUE reader;
|
1213
1213
|
struct rb_libarchive_archive_container *p;
|
1214
1214
|
int r;
|
@@ -1219,7 +1219,9 @@ static VALUE rb_libarchive_reader_s_open0(int (*archive_open)(struct rb_libarchi
|
|
1219
1219
|
rb_raise(rb_eArchiveError, "Open reader failed: %s", strerror(errno));
|
1220
1220
|
}
|
1221
1221
|
|
1222
|
-
if (
|
1222
|
+
if (cmd != NULL) {
|
1223
|
+
r = archive_read_support_compression_program(p->ar, cmd);
|
1224
|
+
} else if (compression != -1) {
|
1223
1225
|
r = archive_read_support_compression(p->ar, compression);
|
1224
1226
|
} else {
|
1225
1227
|
r = archive_read_support_compression_all(p->ar);
|
@@ -1288,11 +1290,15 @@ static VALUE rb_libarchive_reader_s_open_filename(int argc, VALUE *argv, VALUE s
|
|
1288
1290
|
VALUE v_filename, v_compression, v_format;
|
1289
1291
|
const char *filename = NULL;
|
1290
1292
|
int compression = -1, format = -1;
|
1293
|
+
const char *cmd = NULL;
|
1291
1294
|
rb_scan_args(argc, argv, "12", &v_filename, &v_compression, &v_format);
|
1292
1295
|
Check_Type(v_filename, T_STRING);
|
1293
1296
|
filename = RSTRING_PTR(v_filename);
|
1294
1297
|
|
1295
|
-
if (
|
1298
|
+
if (T_STRING == TYPE(v_compression)) {
|
1299
|
+
compression = -1;
|
1300
|
+
cmd = RSTRING_PTR(v_compression);
|
1301
|
+
} else if (!NIL_P(v_compression)) {
|
1296
1302
|
compression = NUM2INT(v_compression);
|
1297
1303
|
}
|
1298
1304
|
|
@@ -1300,7 +1306,7 @@ static VALUE rb_libarchive_reader_s_open_filename(int argc, VALUE *argv, VALUE s
|
|
1300
1306
|
format = NUM2INT(v_format);
|
1301
1307
|
}
|
1302
1308
|
|
1303
|
-
return rb_libarchive_reader_s_open0(rb_libarchive_reader_s_open_filename0, (void *) filename, compression, format);
|
1309
|
+
return rb_libarchive_reader_s_open0(rb_libarchive_reader_s_open_filename0, (void *) filename, compression, format, cmd);
|
1304
1310
|
}
|
1305
1311
|
|
1306
1312
|
static int rb_libarchive_reader_s_open_memory0(struct rb_libarchive_archive_container *p, void *arg) {
|
@@ -1312,10 +1318,14 @@ static int rb_libarchive_reader_s_open_memory0(struct rb_libarchive_archive_cont
|
|
1312
1318
|
static VALUE rb_libarchive_reader_s_open_memory(int argc, VALUE *argv, VALUE self) {
|
1313
1319
|
VALUE v_memory, v_compression, v_format;
|
1314
1320
|
int compression = -1, format = -1;
|
1321
|
+
const char *cmd = NULL;
|
1315
1322
|
rb_scan_args(argc, argv, "12", &v_memory, &v_compression, &v_format);
|
1316
1323
|
Check_Type(v_memory, T_STRING);
|
1317
1324
|
|
1318
|
-
if (
|
1325
|
+
if (T_STRING == TYPE(v_compression)) {
|
1326
|
+
compression = -1;
|
1327
|
+
cmd = RSTRING_PTR(v_compression);
|
1328
|
+
} else if (!NIL_P(v_compression)) {
|
1319
1329
|
compression = NUM2INT(v_compression);
|
1320
1330
|
}
|
1321
1331
|
|
@@ -1323,7 +1333,7 @@ static VALUE rb_libarchive_reader_s_open_memory(int argc, VALUE *argv, VALUE sel
|
|
1323
1333
|
format = NUM2INT(v_format);
|
1324
1334
|
}
|
1325
1335
|
|
1326
|
-
return rb_libarchive_reader_s_open0(rb_libarchive_reader_s_open_memory0, (void *) v_memory, compression, format);
|
1336
|
+
return rb_libarchive_reader_s_open0(rb_libarchive_reader_s_open_memory0, (void *) v_memory, compression, format, cmd);
|
1327
1337
|
}
|
1328
1338
|
|
1329
1339
|
/* */
|
@@ -1494,7 +1504,9 @@ void Init_libarchive_reader() {
|
|
1494
1504
|
rb_define_alloc_func(rb_cArchiveReader, rb_libarchive_archive_alloc);
|
1495
1505
|
rb_funcall(rb_cArchiveReader, rb_intern("private_class_method"), 1, ID2SYM(rb_intern("new")));
|
1496
1506
|
rb_define_singleton_method(rb_cArchiveReader, "open_filename", rb_libarchive_reader_s_open_filename, -1);
|
1507
|
+
rb_define_module_function(rb_mArchive, "read_open_filename", rb_libarchive_reader_s_open_filename, -1);
|
1497
1508
|
rb_define_singleton_method(rb_cArchiveReader, "open_memory", rb_libarchive_reader_s_open_memory, -1);
|
1509
|
+
rb_define_module_function(rb_mArchive, "read_open_memory", rb_libarchive_reader_s_open_memory, -1);
|
1498
1510
|
rb_define_method(rb_cArchiveReader, "close", rb_libarchive_reader_close, 0);
|
1499
1511
|
rb_define_method(rb_cArchiveReader, "next_header", rb_libarchive_reader_next_header, 0);
|
1500
1512
|
rb_define_method(rb_cArchiveReader, "header_position", rb_libarchive_reader_header_position, 0);
|
@@ -1524,9 +1536,10 @@ static VALUE rb_libarchive_writer_close(VALUE self) {
|
|
1524
1536
|
return Qnil;
|
1525
1537
|
}
|
1526
1538
|
|
1527
|
-
static VALUE rb_libarchive_writer_s_open0(int (*archive_open)(struct rb_libarchive_archive_container *, void *), void *arg, int compression, int format) {
|
1539
|
+
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) {
|
1528
1540
|
VALUE writer;
|
1529
1541
|
struct rb_libarchive_archive_container *p;
|
1542
|
+
int r;
|
1530
1543
|
writer = rb_funcall(rb_cArchiveWriter, rb_intern("new"), 0);
|
1531
1544
|
Data_Get_Struct(writer, struct rb_libarchive_archive_container, p);
|
1532
1545
|
|
@@ -1534,7 +1547,13 @@ static VALUE rb_libarchive_writer_s_open0(int (*archive_open)(struct rb_libarchi
|
|
1534
1547
|
rb_raise(rb_eArchiveError, "Open writer failed: %s", strerror(errno));
|
1535
1548
|
}
|
1536
1549
|
|
1537
|
-
if (
|
1550
|
+
if (cmd != NULL) {
|
1551
|
+
r = archive_write_set_compression_program(p->ar, cmd);
|
1552
|
+
} else {
|
1553
|
+
r = archive_write_set_compression(p->ar, compression);
|
1554
|
+
}
|
1555
|
+
|
1556
|
+
if (r != ARCHIVE_OK) {
|
1538
1557
|
char error_string[BUFSIZ];
|
1539
1558
|
archive_copy_error_string(p->ar, error_string, BUFSIZ);
|
1540
1559
|
rb_libarchive_writer_close0(p);
|
@@ -1580,6 +1599,7 @@ static int rb_libarchive_writer_s_open_filename0(struct rb_libarchive_archive_co
|
|
1580
1599
|
static VALUE rb_libarchive_writer_s_open_filename(VALUE self, VALUE v_filename, VALUE v_compression, VALUE v_format) {
|
1581
1600
|
const char *filename = NULL;
|
1582
1601
|
int compression, format;
|
1602
|
+
const char *cmd = NULL;
|
1583
1603
|
Check_Type(v_filename, T_STRING);
|
1584
1604
|
|
1585
1605
|
if (RSTRING_LEN(v_filename) < 1) {
|
@@ -1587,9 +1607,17 @@ static VALUE rb_libarchive_writer_s_open_filename(VALUE self, VALUE v_filename,
|
|
1587
1607
|
}
|
1588
1608
|
|
1589
1609
|
filename = RSTRING_PTR(v_filename);
|
1590
|
-
|
1610
|
+
|
1611
|
+
if (T_STRING == TYPE(v_compression)) {
|
1612
|
+
compression = -1;
|
1613
|
+
cmd = RSTRING_PTR(v_compression);
|
1614
|
+
} else {
|
1615
|
+
compression = NUM2INT(v_compression);
|
1616
|
+
}
|
1617
|
+
|
1618
|
+
|
1591
1619
|
format = NUM2INT(v_format);
|
1592
|
-
return rb_libarchive_writer_s_open0(rb_libarchive_writer_s_open_filename0, (void *) filename, compression, format);
|
1620
|
+
return rb_libarchive_writer_s_open0(rb_libarchive_writer_s_open_filename0, (void *) filename, compression, format, cmd);
|
1593
1621
|
}
|
1594
1622
|
|
1595
1623
|
static int rb_libarchive_writer_s_open_memory0(struct rb_libarchive_archive_container *p, void *arg) {
|
@@ -1601,10 +1629,18 @@ static int rb_libarchive_writer_s_open_memory0(struct rb_libarchive_archive_cont
|
|
1601
1629
|
/* */
|
1602
1630
|
static VALUE rb_libarchive_writer_s_open_memory(VALUE self, VALUE v_memory, VALUE v_compression, VALUE v_format) {
|
1603
1631
|
int compression, format;
|
1632
|
+
const char *cmd = NULL;
|
1604
1633
|
Check_Type(v_memory, T_STRING);
|
1605
|
-
|
1634
|
+
|
1635
|
+
if (T_STRING == TYPE(v_compression)) {
|
1636
|
+
compression = -1;
|
1637
|
+
cmd = RSTRING_PTR(v_compression);
|
1638
|
+
} else {
|
1639
|
+
compression = NUM2INT(v_compression);
|
1640
|
+
}
|
1641
|
+
|
1606
1642
|
format = NUM2INT(v_format);
|
1607
|
-
return rb_libarchive_writer_s_open0(rb_libarchive_writer_s_open_memory0, (void *) v_memory, compression, format);
|
1643
|
+
return rb_libarchive_writer_s_open0(rb_libarchive_writer_s_open_memory0, (void *) v_memory, compression, format, cmd);
|
1608
1644
|
}
|
1609
1645
|
|
1610
1646
|
/* */
|
@@ -1716,7 +1752,9 @@ void Init_libarchive_writer() {
|
|
1716
1752
|
rb_define_alloc_func(rb_cArchiveWriter, rb_libarchive_archive_alloc);
|
1717
1753
|
rb_funcall(rb_cArchiveWriter, rb_intern("private_class_method"), 1, ID2SYM(rb_intern("new")));
|
1718
1754
|
rb_define_singleton_method(rb_cArchiveWriter, "open_filename", rb_libarchive_writer_s_open_filename, 3);
|
1755
|
+
rb_define_singleton_method(rb_mArchive, "write_open_filename", rb_libarchive_writer_s_open_filename, 3);
|
1719
1756
|
rb_define_singleton_method(rb_cArchiveWriter, "open_memory", rb_libarchive_writer_s_open_memory, 3);
|
1757
|
+
rb_define_singleton_method(rb_mArchive, "write_open_memory", rb_libarchive_writer_s_open_memory, 3);
|
1720
1758
|
rb_define_method(rb_cArchiveWriter, "close", rb_libarchive_writer_close, 0);
|
1721
1759
|
rb_define_method(rb_cArchiveWriter, "new_entry", rb_libarchive_writer_new_entry, 0);
|
1722
1760
|
rb_define_method(rb_cArchiveWriter, "write_header", rb_libarchive_writer_write_header, 1);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libarchive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- winebarrel
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-30 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -22,6 +22,8 @@ extensions:
|
|
22
22
|
extra_rdoc_files:
|
23
23
|
- README.txt
|
24
24
|
- libarchive.c
|
25
|
+
- COPYING.libarchive
|
26
|
+
- LICENSE.libbzip2
|
25
27
|
files:
|
26
28
|
- ext/configure
|
27
29
|
- ext/archive_read_support_compression.h
|
@@ -47,6 +49,8 @@ files:
|
|
47
49
|
- ext/archive_write_open_rb_str.h
|
48
50
|
- README.txt
|
49
51
|
- libarchive.c
|
52
|
+
- COPYING.libarchive
|
53
|
+
- LICENSE.libbzip2
|
50
54
|
has_rdoc: true
|
51
55
|
homepage: http://libarchive.rubyforge.org
|
52
56
|
post_install_message:
|