dguerri-libarchive 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/COPYING.libarchive +60 -0
- data/LICENSE.libbzip2 +42 -0
- data/README.txt +143 -0
- data/ext/Makefile.in +0 -0
- data/ext/archive_read_support_compression.c +31 -0
- data/ext/archive_read_support_compression.h +6 -0
- data/ext/archive_read_support_format.c +32 -0
- data/ext/archive_read_support_format.h +6 -0
- data/ext/archive_write_open_rb_str.c +29 -0
- data/ext/archive_write_open_rb_str.h +6 -0
- data/ext/archive_write_set_compression.c +32 -0
- data/ext/archive_write_set_compression.h +6 -0
- data/ext/config.h.in +22 -0
- data/ext/configure +3904 -0
- data/ext/configure.in +11 -0
- data/ext/depend +19 -0
- data/ext/extconf.rb +6 -0
- data/ext/install-sh +250 -0
- data/ext/libarchive.c +89 -0
- data/ext/libarchive_archive.c +84 -0
- data/ext/libarchive_entry.c +1015 -0
- data/ext/libarchive_internal.h +155 -0
- data/ext/libarchive_reader.c +328 -0
- data/ext/libarchive_win32.h +52 -0
- data/ext/libarchive_writer.c +246 -0
- data/libarchive.c +1762 -0
- metadata +98 -0
data/CHANGELOG
ADDED
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
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
= Libarchive/Ruby
|
2
|
+
|
3
|
+
Copyright (c) 2009 SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
4
|
+
|
5
|
+
== Description
|
6
|
+
|
7
|
+
Ruby bindings for Libarchive.
|
8
|
+
|
9
|
+
Libarchive is a programming library that can create and read several different streaming archive formats, including most popular tar variants, several cpio formats, and both BSD and GNU ar variants.
|
10
|
+
|
11
|
+
== Support archive (from Libarchive 2.6.0)
|
12
|
+
=== reading
|
13
|
+
* gzip compression
|
14
|
+
* bzip2 compression
|
15
|
+
* compress/LZW compression
|
16
|
+
* GNU tar format (including GNU long filenames, long link names, and
|
17
|
+
sparse files)
|
18
|
+
* Solaris 9 extended tar format (including ACLs)
|
19
|
+
* Old V7 tar archives
|
20
|
+
* POSIX ustar
|
21
|
+
* POSIX pax interchange format
|
22
|
+
* POSIX octet-oriented cpio
|
23
|
+
* SVR4 ASCII cpio
|
24
|
+
* Binary cpio (big-endian or little-endian)
|
25
|
+
* ISO9660 CD-ROM images (with optional Rockridge extensions)
|
26
|
+
* ZIP archives (with uncompressed or "deflate" compressed entries)
|
27
|
+
* GNU and BSD 'ar' archives
|
28
|
+
* 'mtree' format
|
29
|
+
* lzma compression not supported
|
30
|
+
|
31
|
+
=== writing
|
32
|
+
* gzip compression
|
33
|
+
* bzip2 compression
|
34
|
+
* compress/LZW compression
|
35
|
+
* POSIX ustar
|
36
|
+
* POSIX pax interchange format
|
37
|
+
* "restricted" pax format, which will create ustar archives except for entries that require pax extensions (for long filenames, etc).
|
38
|
+
* ACLs not supported
|
39
|
+
* POSIX octet-oriented cpio
|
40
|
+
* SVR4 "newc" cpio
|
41
|
+
* shar archives
|
42
|
+
* GNU and BSD 'ar' archives
|
43
|
+
|
44
|
+
== Project Page
|
45
|
+
|
46
|
+
http://rubyforge.org/projects/libarchive
|
47
|
+
|
48
|
+
== Source Code
|
49
|
+
|
50
|
+
http://coderepos.org/share/browser/lang/ruby/libarchive/trunk/
|
51
|
+
|
52
|
+
== Dependency
|
53
|
+
|
54
|
+
Libarchive/Ruby depend on Libarchive.
|
55
|
+
|
56
|
+
Please install Libarchive. (version 2.6.0 or more is recommended)
|
57
|
+
|
58
|
+
== Install
|
59
|
+
|
60
|
+
gem install libarchive
|
61
|
+
|
62
|
+
== Example
|
63
|
+
=== reading archive
|
64
|
+
require 'libarchive_ruby'
|
65
|
+
|
66
|
+
Archive.read_open_filename('foo.tar.gz') do |ar|
|
67
|
+
while entry = ar.next_header
|
68
|
+
name = entry.pathname
|
69
|
+
data = ar.read_data
|
70
|
+
|
71
|
+
#data = ""
|
72
|
+
#ar.read_data(1024) do |x|
|
73
|
+
# data << x
|
74
|
+
#end
|
75
|
+
|
76
|
+
puts "#{name} (size=#{data.size})"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
=== creating archive
|
81
|
+
require 'libarchive_ruby'
|
82
|
+
|
83
|
+
Archive.write_open_filename('foo.tar.bz2', Archive::COMPRESSION_BZIP2, Archive::FORMAT_TAR_USTAR) do |ar|
|
84
|
+
Dir.glob('*.c').each do |fn|
|
85
|
+
ar.new_entry do |entry|
|
86
|
+
entry.copy_stat(fn)
|
87
|
+
entry.pathname = fn
|
88
|
+
ar.write_header(entry)
|
89
|
+
ar.write_data(open(fn) {|f| f.read })
|
90
|
+
|
91
|
+
#open(fn) do |f|
|
92
|
+
# ar.write_data do
|
93
|
+
# f.read(1024)
|
94
|
+
# end
|
95
|
+
#end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
=== creating archive by extarnal program
|
101
|
+
require 'libarchive_ruby'
|
102
|
+
|
103
|
+
Archive.write_open_filename('foo.tar.lzo', 'lzop', Archive::FORMAT_TAR_USTAR) do |ar|
|
104
|
+
...
|
105
|
+
end
|
106
|
+
|
107
|
+
== License
|
108
|
+
Copyright (c) 2009 SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
109
|
+
All rights reserved.
|
110
|
+
|
111
|
+
Redistribution and use in source and binary forms, with or without modification,
|
112
|
+
are permitted provided that the following conditions are met:
|
113
|
+
|
114
|
+
* Redistributions of source code must retain the above copyright notice,
|
115
|
+
this list of conditions and the following disclaimer.
|
116
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
117
|
+
this list of conditions and the following disclaimer in the documentation
|
118
|
+
and/or other materials provided with the distribution.
|
119
|
+
* The names of its contributors may be used to endorse or promote products
|
120
|
+
derived from this software without specific prior written permission.
|
121
|
+
|
122
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
123
|
+
ANY EXPRESS OR IMPLIED WARRANTIES,
|
124
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
125
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
126
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
127
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
128
|
+
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
129
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
130
|
+
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
131
|
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
132
|
+
DAMAGE.
|
133
|
+
|
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]
|
data/ext/Makefile.in
ADDED
File without changes
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#include <errno.h>
|
2
|
+
#include <archive.h>
|
3
|
+
|
4
|
+
static struct {
|
5
|
+
int code;
|
6
|
+
int (*setter)(struct archive *);
|
7
|
+
} codes[] = {
|
8
|
+
{ ARCHIVE_COMPRESSION_NONE, archive_read_support_compression_none },
|
9
|
+
{ ARCHIVE_COMPRESSION_GZIP, archive_read_support_compression_gzip },
|
10
|
+
{ ARCHIVE_COMPRESSION_BZIP2, archive_read_support_compression_bzip2 },
|
11
|
+
{ ARCHIVE_COMPRESSION_COMPRESS, archive_read_support_compression_compress },
|
12
|
+
// XXX:
|
13
|
+
/*
|
14
|
+
{ ARCHIVE_COMPRESSION_PROGRAM, archive_read_support_compression_program },
|
15
|
+
{ ARCHIVE_COMPRESSION_LZMA, archive_read_support_compression_lzma },
|
16
|
+
*/
|
17
|
+
{ -1, NULL },
|
18
|
+
};
|
19
|
+
|
20
|
+
int archive_read_support_compression(struct archive *a, int code) {
|
21
|
+
int i;
|
22
|
+
|
23
|
+
for (i = 0; codes[i].code >= 0; i++) {
|
24
|
+
if (codes[i].code == code) {
|
25
|
+
return codes[i].setter(a);
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
archive_set_error(a, EINVAL, "No such compression");
|
30
|
+
return ARCHIVE_FATAL;
|
31
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#include <errno.h>
|
2
|
+
#include <archive.h>
|
3
|
+
|
4
|
+
static struct {
|
5
|
+
int code;
|
6
|
+
int (*setter)(struct archive *);
|
7
|
+
} codes[] = {
|
8
|
+
{ ARCHIVE_FORMAT_CPIO, archive_read_support_format_cpio },
|
9
|
+
{ ARCHIVE_FORMAT_TAR, archive_read_support_format_tar },
|
10
|
+
{ ARCHIVE_FORMAT_TAR_GNUTAR, archive_read_support_format_gnutar },
|
11
|
+
{ ARCHIVE_FORMAT_ISO9660, archive_read_support_format_iso9660 },
|
12
|
+
{ ARCHIVE_FORMAT_ZIP, archive_read_support_format_zip },
|
13
|
+
{ ARCHIVE_FORMAT_EMPTY, archive_read_support_format_empty },
|
14
|
+
{ ARCHIVE_FORMAT_AR, archive_read_support_format_ar },
|
15
|
+
#ifdef ARCHIVE_FORMAT_MTREE
|
16
|
+
{ ARCHIVE_FORMAT_MTREE, archive_read_support_format_mtree },
|
17
|
+
#endif
|
18
|
+
{ -1, NULL },
|
19
|
+
};
|
20
|
+
|
21
|
+
int archive_read_support_format(struct archive *a, int code) {
|
22
|
+
int i;
|
23
|
+
|
24
|
+
for (i = 0; codes[i].code >= 0; i++) {
|
25
|
+
if (codes[i].code == code) {
|
26
|
+
return codes[i].setter(a);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
archive_set_error(a, EINVAL, "No such format");
|
31
|
+
return ARCHIVE_FATAL;
|
32
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#include <archive.h>
|
2
|
+
#include <ruby.h>
|
3
|
+
|
4
|
+
#ifdef _WIN32
|
5
|
+
typedef long ssize_t;
|
6
|
+
#endif
|
7
|
+
|
8
|
+
static int rb_str_write_open(struct archive *a, void *client_data) {
|
9
|
+
if (archive_write_get_bytes_in_last_block(a) == -1) {
|
10
|
+
archive_write_set_bytes_in_last_block(a, 1);
|
11
|
+
}
|
12
|
+
|
13
|
+
return ARCHIVE_OK;
|
14
|
+
}
|
15
|
+
|
16
|
+
static int rb_str_write_close(struct archive *a, void *client_data) {
|
17
|
+
return ARCHIVE_OK;
|
18
|
+
}
|
19
|
+
|
20
|
+
|
21
|
+
static ssize_t rb_str_write(struct archive *a, void *client_data, const void *buff, size_t length) {
|
22
|
+
VALUE str = (VALUE) client_data;
|
23
|
+
rb_str_cat(str, buff, length);
|
24
|
+
return length;
|
25
|
+
}
|
26
|
+
|
27
|
+
int archive_write_open_rb_str(struct archive *a, VALUE str) {
|
28
|
+
return archive_write_open(a, (void *) str, rb_str_write_open, rb_str_write, rb_str_write_close);
|
29
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#include <errno.h>
|
2
|
+
#include <archive.h>
|
3
|
+
|
4
|
+
static struct {
|
5
|
+
int code;
|
6
|
+
int (*setter)(struct archive *);
|
7
|
+
} codes[] = {
|
8
|
+
{ ARCHIVE_COMPRESSION_NONE, archive_write_set_compression_none },
|
9
|
+
{ ARCHIVE_COMPRESSION_GZIP, archive_write_set_compression_gzip },
|
10
|
+
{ ARCHIVE_COMPRESSION_BZIP2, archive_write_set_compression_bzip2 },
|
11
|
+
#if ARCHIVE_VERSION_NUMBER >= 2005000
|
12
|
+
{ ARCHIVE_COMPRESSION_COMPRESS, archive_write_set_compression_compress },
|
13
|
+
#endif
|
14
|
+
// XXX:
|
15
|
+
/*
|
16
|
+
{ ARCHIVE_COMPRESSION_PROGRAM, archive_read_support_compression_program },
|
17
|
+
*/
|
18
|
+
{ -1, NULL },
|
19
|
+
};
|
20
|
+
|
21
|
+
int archive_write_set_compression(struct archive *a, int code) {
|
22
|
+
int i;
|
23
|
+
|
24
|
+
for (i = 0; codes[i].code >= 0; i++) {
|
25
|
+
if (codes[i].code == code) {
|
26
|
+
return codes[i].setter(a);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
archive_set_error(a, EINVAL, "No such compression");
|
31
|
+
return ARCHIVE_FATAL;
|
32
|
+
}
|
data/ext/config.h.in
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
/* config.h.in. Generated from configure.in by autoheader. */
|
2
|
+
|
3
|
+
/* Define to the address where bug reports for this package should be sent. */
|
4
|
+
#undef PACKAGE_BUGREPORT
|
5
|
+
|
6
|
+
/* Define to the full name of this package. */
|
7
|
+
#undef PACKAGE_NAME
|
8
|
+
|
9
|
+
/* Define to the full name and version of this package. */
|
10
|
+
#undef PACKAGE_STRING
|
11
|
+
|
12
|
+
/* Define to the one symbol short name of this package. */
|
13
|
+
#undef PACKAGE_TARNAME
|
14
|
+
|
15
|
+
/* Define to the version of this package. */
|
16
|
+
#undef PACKAGE_VERSION
|
17
|
+
|
18
|
+
/* Number of bits in a file offset, on hosts where this is settable. */
|
19
|
+
#undef _FILE_OFFSET_BITS
|
20
|
+
|
21
|
+
/* Define for large files, on AIX-style hosts. */
|
22
|
+
#undef _LARGE_FILES
|