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