libarchive-ruby-fs 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ext/rblibarchive/archive_read_support_compression.c +31 -0
- data/ext/rblibarchive/archive_read_support_compression.h +6 -0
- data/ext/rblibarchive/archive_read_support_format.c +32 -0
- data/ext/rblibarchive/archive_read_support_format.h +6 -0
- data/ext/rblibarchive/archive_write_open_rb_str.c +25 -0
- data/ext/rblibarchive/archive_write_open_rb_str.h +6 -0
- data/ext/rblibarchive/archive_write_set_compression.c +32 -0
- data/ext/rblibarchive/archive_write_set_compression.h +6 -0
- data/ext/rblibarchive/extconf.rb +20 -0
- data/ext/rblibarchive/libarchive.c +92 -0
- data/ext/rblibarchive/libarchive_archive.c +84 -0
- data/ext/rblibarchive/libarchive_entry.c +1015 -0
- data/ext/rblibarchive/libarchive_internal.h +134 -0
- data/ext/rblibarchive/libarchive_reader.c +328 -0
- data/ext/rblibarchive/libarchive_writer.c +246 -0
- data/lib/libarchive-ruby-fs/version.rb +3 -0
- data/lib/libarchive-ruby-fs.rb +5 -0
- metadata +77 -0
@@ -0,0 +1,1015 @@
|
|
1
|
+
#include "libarchive_internal.h"
|
2
|
+
|
3
|
+
extern VALUE rb_mArchive;
|
4
|
+
VALUE rb_cArchiveEntry;
|
5
|
+
extern VALUE rb_eArchiveError;
|
6
|
+
|
7
|
+
static void rb_libarchive_entry_free(struct rb_libarchive_entry_container *p) {
|
8
|
+
xfree(p);
|
9
|
+
}
|
10
|
+
|
11
|
+
static VALUE rb_libarchive_entry_alloc(VALUE klass) {
|
12
|
+
struct rb_libarchive_entry_container *p = ALLOC(struct rb_libarchive_entry_container);
|
13
|
+
p->ae = NULL;
|
14
|
+
p->must_close = 1;
|
15
|
+
return Data_Wrap_Struct(klass, 0, rb_libarchive_entry_free, p);
|
16
|
+
}
|
17
|
+
|
18
|
+
/* */
|
19
|
+
VALUE rb_libarchive_entry_close(VALUE self) {
|
20
|
+
struct rb_libarchive_entry_container *p;
|
21
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
22
|
+
Check_Entry(p);
|
23
|
+
|
24
|
+
if (!p->must_close) {
|
25
|
+
rb_raise(rb_eArchiveError, "Close entry failed: It is not necessary to close");
|
26
|
+
}
|
27
|
+
|
28
|
+
archive_entry_free(p->ae);
|
29
|
+
p->ae = NULL;
|
30
|
+
return Qnil;
|
31
|
+
}
|
32
|
+
|
33
|
+
VALUE rb_libarchive_entry_new(struct archive_entry *ae, int must_close) {
|
34
|
+
VALUE entry;
|
35
|
+
struct rb_libarchive_entry_container *p;
|
36
|
+
entry = rb_funcall(rb_cArchiveEntry, rb_intern("new"), 0);
|
37
|
+
Data_Get_Struct(entry, struct rb_libarchive_entry_container, p);
|
38
|
+
p->ae = ae;
|
39
|
+
p->must_close = must_close;
|
40
|
+
return entry;
|
41
|
+
}
|
42
|
+
|
43
|
+
/* */
|
44
|
+
static VALUE rb_libarchive_entry_atime(VALUE self) {
|
45
|
+
struct rb_libarchive_entry_container *p;
|
46
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
47
|
+
Check_Entry(p);
|
48
|
+
return LONG2TIME((long) archive_entry_atime(p->ae));
|
49
|
+
}
|
50
|
+
|
51
|
+
/* */
|
52
|
+
static VALUE rb_libarchive_entry_atime_nsec(VALUE self) {
|
53
|
+
struct rb_libarchive_entry_container *p;
|
54
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
55
|
+
Check_Entry(p);
|
56
|
+
return LONG2NUM(archive_entry_atime_nsec(p->ae));
|
57
|
+
}
|
58
|
+
|
59
|
+
/* */
|
60
|
+
static VALUE rb_libarchive_entry_atime_is_set(VALUE self) {
|
61
|
+
struct rb_libarchive_entry_container *p;
|
62
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
63
|
+
Check_Entry(p);
|
64
|
+
return archive_entry_atime_is_set(p->ae) ? Qtrue : Qfalse;
|
65
|
+
}
|
66
|
+
|
67
|
+
/* */
|
68
|
+
static VALUE rb_libarchive_entry_birthtime(VALUE self) {
|
69
|
+
struct rb_libarchive_entry_container *p;
|
70
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
71
|
+
Check_Entry(p);
|
72
|
+
return LONG2TIME((long) archive_entry_birthtime(p->ae));
|
73
|
+
}
|
74
|
+
|
75
|
+
/* */
|
76
|
+
static VALUE rb_libarchive_entry_birthtime_nsec(VALUE self) {
|
77
|
+
struct rb_libarchive_entry_container *p;
|
78
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
79
|
+
Check_Entry(p);
|
80
|
+
return LONG2NUM(archive_entry_birthtime_nsec(p->ae));
|
81
|
+
}
|
82
|
+
|
83
|
+
/* */
|
84
|
+
static VALUE rb_libarchive_entry_birthtime_is_set(VALUE self) {
|
85
|
+
struct rb_libarchive_entry_container *p;
|
86
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
87
|
+
Check_Entry(p);
|
88
|
+
return archive_entry_birthtime_is_set(p->ae) ? Qtrue : Qfalse;
|
89
|
+
}
|
90
|
+
|
91
|
+
/* */
|
92
|
+
static VALUE rb_libarchive_entry_ctime(VALUE self) {
|
93
|
+
struct rb_libarchive_entry_container *p;
|
94
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
95
|
+
Check_Entry(p);
|
96
|
+
return LONG2TIME((long) archive_entry_ctime(p->ae));
|
97
|
+
}
|
98
|
+
|
99
|
+
/* */
|
100
|
+
static VALUE rb_libarchive_entry_ctime_nsec(VALUE self) {
|
101
|
+
struct rb_libarchive_entry_container *p;
|
102
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
103
|
+
Check_Entry(p);
|
104
|
+
return LONG2NUM(archive_entry_ctime_nsec(p->ae));
|
105
|
+
}
|
106
|
+
|
107
|
+
/* */
|
108
|
+
static VALUE rb_libarchive_entry_ctime_is_set(VALUE self) {
|
109
|
+
struct rb_libarchive_entry_container *p;
|
110
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
111
|
+
Check_Entry(p);
|
112
|
+
return archive_entry_ctime_is_set(p->ae) ? Qtrue : Qfalse;
|
113
|
+
}
|
114
|
+
|
115
|
+
/* */
|
116
|
+
static VALUE rb_libarchive_entry_dev(VALUE self) {
|
117
|
+
struct rb_libarchive_entry_container *p;
|
118
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
119
|
+
Check_Entry(p);
|
120
|
+
return LONG2NUM(archive_entry_dev(p->ae));
|
121
|
+
}
|
122
|
+
|
123
|
+
/* */
|
124
|
+
static VALUE rb_libarchive_entry_devmajor(VALUE self) {
|
125
|
+
struct rb_libarchive_entry_container *p;
|
126
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
127
|
+
Check_Entry(p);
|
128
|
+
return LONG2NUM(archive_entry_devmajor(p->ae));
|
129
|
+
}
|
130
|
+
|
131
|
+
/* */
|
132
|
+
static VALUE rb_libarchive_entry_devminor(VALUE self) {
|
133
|
+
struct rb_libarchive_entry_container *p;
|
134
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
135
|
+
Check_Entry(p);
|
136
|
+
return LONG2NUM(archive_entry_devminor(p->ae));
|
137
|
+
}
|
138
|
+
|
139
|
+
/* */
|
140
|
+
static VALUE rb_libarchive_entry_filetype(VALUE self) {
|
141
|
+
struct rb_libarchive_entry_container *p;
|
142
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
143
|
+
Check_Entry(p);
|
144
|
+
return INT2NUM(archive_entry_filetype(p->ae));
|
145
|
+
}
|
146
|
+
|
147
|
+
/* */
|
148
|
+
static VALUE rb_libarchive_entry_is_directory(VALUE self) {
|
149
|
+
struct rb_libarchive_entry_container *p;
|
150
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
151
|
+
Check_Entry(p);
|
152
|
+
return S_ISDIR(archive_entry_filetype(p->ae)) ? Qtrue : Qfalse;
|
153
|
+
}
|
154
|
+
|
155
|
+
/* */
|
156
|
+
static VALUE rb_libarchive_entry_is_character_special(VALUE self) {
|
157
|
+
struct rb_libarchive_entry_container *p;
|
158
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
159
|
+
Check_Entry(p);
|
160
|
+
return S_ISCHR(archive_entry_filetype(p->ae)) ? Qtrue : Qfalse;
|
161
|
+
}
|
162
|
+
|
163
|
+
/* */
|
164
|
+
static VALUE rb_libarchive_entry_is_block_special(VALUE self) {
|
165
|
+
struct rb_libarchive_entry_container *p;
|
166
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
167
|
+
Check_Entry(p);
|
168
|
+
return S_ISBLK(archive_entry_filetype(p->ae)) ? Qtrue : Qfalse;
|
169
|
+
}
|
170
|
+
|
171
|
+
/* */
|
172
|
+
static VALUE rb_libarchive_entry_is_regular(VALUE self) {
|
173
|
+
struct rb_libarchive_entry_container *p;
|
174
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
175
|
+
Check_Entry(p);
|
176
|
+
return S_ISREG(archive_entry_filetype(p->ae)) ? Qtrue : Qfalse;
|
177
|
+
}
|
178
|
+
|
179
|
+
/* */
|
180
|
+
static VALUE rb_libarchive_entry_is_symbolic_link(VALUE self) {
|
181
|
+
struct rb_libarchive_entry_container *p;
|
182
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
183
|
+
Check_Entry(p);
|
184
|
+
return S_ISLNK(archive_entry_filetype(p->ae)) ? Qtrue : Qfalse;
|
185
|
+
}
|
186
|
+
|
187
|
+
/* */
|
188
|
+
static VALUE rb_libarchive_entry_is_socket(VALUE self) {
|
189
|
+
struct rb_libarchive_entry_container *p;
|
190
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
191
|
+
Check_Entry(p);
|
192
|
+
return S_ISSOCK(archive_entry_filetype(p->ae)) ? Qtrue : Qfalse;
|
193
|
+
}
|
194
|
+
|
195
|
+
/* */
|
196
|
+
static VALUE rb_libarchive_entry_is_fifo(VALUE self) {
|
197
|
+
struct rb_libarchive_entry_container *p;
|
198
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
199
|
+
Check_Entry(p);
|
200
|
+
return S_ISFIFO(archive_entry_filetype(p->ae)) ? Qtrue : Qfalse;
|
201
|
+
}
|
202
|
+
|
203
|
+
/* */
|
204
|
+
static VALUE rb_libarchive_entry_fflags(VALUE self) {
|
205
|
+
struct rb_libarchive_entry_container *p;
|
206
|
+
long set, clear;
|
207
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
208
|
+
Check_Entry(p);
|
209
|
+
archive_entry_fflags(p->ae, &set, &clear);
|
210
|
+
return rb_ary_new3(2, LONG2NUM(set), LONG2NUM(clear));
|
211
|
+
}
|
212
|
+
|
213
|
+
/* */
|
214
|
+
static VALUE rb_libarchive_entry_fflags_text(VALUE self) {
|
215
|
+
struct rb_libarchive_entry_container *p;
|
216
|
+
const char *fflags_text;
|
217
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
218
|
+
Check_Entry(p);
|
219
|
+
fflags_text = archive_entry_fflags_text(p->ae);
|
220
|
+
return (fflags_text != NULL) ? rb_str_new2(fflags_text) : Qnil;
|
221
|
+
}
|
222
|
+
|
223
|
+
/* */
|
224
|
+
static VALUE rb_libarchive_entry_gid(VALUE self) {
|
225
|
+
struct rb_libarchive_entry_container *p;
|
226
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
227
|
+
Check_Entry(p);
|
228
|
+
return LONG2NUM(archive_entry_gid(p->ae));
|
229
|
+
}
|
230
|
+
|
231
|
+
/* */
|
232
|
+
static VALUE rb_libarchive_entry_gname(VALUE self) {
|
233
|
+
struct rb_libarchive_entry_container *p;
|
234
|
+
const char *gname;
|
235
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
236
|
+
Check_Entry(p);
|
237
|
+
gname = archive_entry_gname(p->ae);
|
238
|
+
return (gname != NULL) ? rb_str_new2(gname) : Qnil;
|
239
|
+
}
|
240
|
+
|
241
|
+
/* */
|
242
|
+
static VALUE rb_libarchive_entry_hardlink(VALUE self) {
|
243
|
+
struct rb_libarchive_entry_container *p;
|
244
|
+
const char *hardlink;
|
245
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
246
|
+
Check_Entry(p);
|
247
|
+
hardlink = archive_entry_hardlink(p->ae);
|
248
|
+
return (hardlink != NULL) ? rb_str_new2(hardlink) : Qnil;
|
249
|
+
}
|
250
|
+
|
251
|
+
/* */
|
252
|
+
static VALUE rb_libarchive_entry_ino(VALUE self) {
|
253
|
+
struct rb_libarchive_entry_container *p;
|
254
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
255
|
+
return LONG2NUM(archive_entry_ino(p->ae));
|
256
|
+
}
|
257
|
+
|
258
|
+
/* */
|
259
|
+
static VALUE rb_libarchive_entry_mode(VALUE self) {
|
260
|
+
struct rb_libarchive_entry_container *p;
|
261
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
262
|
+
return LONG2NUM(archive_entry_mode(p->ae));
|
263
|
+
}
|
264
|
+
|
265
|
+
/* */
|
266
|
+
static VALUE rb_libarchive_entry_mtime(VALUE self) {
|
267
|
+
struct rb_libarchive_entry_container *p;
|
268
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
269
|
+
Check_Entry(p);
|
270
|
+
return LONG2TIME((long) archive_entry_mtime(p->ae));
|
271
|
+
}
|
272
|
+
|
273
|
+
/* */
|
274
|
+
static VALUE rb_libarchive_entry_mtime_nsec(VALUE self) {
|
275
|
+
struct rb_libarchive_entry_container *p;
|
276
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
277
|
+
Check_Entry(p);
|
278
|
+
return LONG2NUM(archive_entry_mtime_nsec(p->ae));
|
279
|
+
}
|
280
|
+
|
281
|
+
/* */
|
282
|
+
static VALUE rb_libarchive_entry_mtime_is_set(VALUE self) {
|
283
|
+
struct rb_libarchive_entry_container *p;
|
284
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
285
|
+
Check_Entry(p);
|
286
|
+
return archive_entry_mtime_is_set(p->ae) ? Qtrue : Qfalse;
|
287
|
+
}
|
288
|
+
|
289
|
+
/* */
|
290
|
+
static VALUE rb_libarchive_entry_nlink(VALUE self) {
|
291
|
+
struct rb_libarchive_entry_container *p;
|
292
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
293
|
+
Check_Entry(p);
|
294
|
+
return LONG2NUM(archive_entry_nlink(p->ae));
|
295
|
+
}
|
296
|
+
|
297
|
+
/* */
|
298
|
+
static VALUE rb_libarchive_entry_pathname(VALUE self) {
|
299
|
+
struct rb_libarchive_entry_container *p;
|
300
|
+
const char *pathname;
|
301
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
302
|
+
Check_Entry(p);
|
303
|
+
pathname = archive_entry_pathname(p->ae);
|
304
|
+
return (pathname != NULL) ? rb_str_new2(pathname) : Qnil;
|
305
|
+
}
|
306
|
+
|
307
|
+
/* */
|
308
|
+
static VALUE rb_libarchive_entry_rdev(VALUE self) {
|
309
|
+
struct rb_libarchive_entry_container *p;
|
310
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
311
|
+
Check_Entry(p);
|
312
|
+
return LONG2NUM(archive_entry_rdev(p->ae));
|
313
|
+
}
|
314
|
+
|
315
|
+
/* */
|
316
|
+
static VALUE rb_libarchive_entry_rdevmajor(VALUE self) {
|
317
|
+
struct rb_libarchive_entry_container *p;
|
318
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
319
|
+
Check_Entry(p);
|
320
|
+
return LONG2NUM(archive_entry_rdevmajor(p->ae));
|
321
|
+
}
|
322
|
+
|
323
|
+
/* */
|
324
|
+
static VALUE rb_libarchive_entry_rdevminor(VALUE self) {
|
325
|
+
struct rb_libarchive_entry_container *p;
|
326
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
327
|
+
Check_Entry(p);
|
328
|
+
return LONG2NUM(archive_entry_rdevminor(p->ae));
|
329
|
+
}
|
330
|
+
|
331
|
+
#if ARCHIVE_VERSION_NUMBER >= 2005003
|
332
|
+
/* */
|
333
|
+
static VALUE rb_libarchive_entry_sourcepath(VALUE self) {
|
334
|
+
struct rb_libarchive_entry_container *p;
|
335
|
+
const char *sourcepath;
|
336
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
337
|
+
Check_Entry(p);
|
338
|
+
sourcepath = archive_entry_sourcepath(p->ae);
|
339
|
+
return (sourcepath != NULL) ? rb_str_new2(sourcepath) : Qnil;
|
340
|
+
}
|
341
|
+
#endif
|
342
|
+
|
343
|
+
/* */
|
344
|
+
static VALUE rb_libarchive_entry_size(VALUE self) {
|
345
|
+
struct rb_libarchive_entry_container *p;
|
346
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
347
|
+
Check_Entry(p);
|
348
|
+
return LONG2NUM(archive_entry_size(p->ae));
|
349
|
+
}
|
350
|
+
|
351
|
+
/* */
|
352
|
+
static VALUE rb_libarchive_entry_size_is_set(VALUE self) {
|
353
|
+
struct rb_libarchive_entry_container *p;
|
354
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
355
|
+
Check_Entry(p);
|
356
|
+
return archive_entry_size_is_set(p->ae) ? Qtrue : Qfalse;
|
357
|
+
}
|
358
|
+
|
359
|
+
#if ARCHIVE_VERSION_NUMBER >= 2003002
|
360
|
+
/* */
|
361
|
+
static VALUE rb_libarchive_entry_strmode(VALUE self) {
|
362
|
+
struct rb_libarchive_entry_container *p;
|
363
|
+
const char *strmode;
|
364
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
365
|
+
Check_Entry(p);
|
366
|
+
strmode = archive_entry_strmode(p->ae);
|
367
|
+
return (strmode != NULL) ? rb_str_new2(strmode) : Qnil;
|
368
|
+
}
|
369
|
+
#endif
|
370
|
+
|
371
|
+
/* */
|
372
|
+
static VALUE rb_libarchive_entry_symlink(VALUE self) {
|
373
|
+
struct rb_libarchive_entry_container *p;
|
374
|
+
const char *symlink;
|
375
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
376
|
+
Check_Entry(p);
|
377
|
+
symlink = archive_entry_symlink(p->ae);
|
378
|
+
return (symlink != NULL) ? rb_str_new2(symlink) : Qnil;
|
379
|
+
}
|
380
|
+
|
381
|
+
/* */
|
382
|
+
static VALUE rb_libarchive_entry_uid(VALUE self) {
|
383
|
+
struct rb_libarchive_entry_container *p;
|
384
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
385
|
+
Check_Entry(p);
|
386
|
+
return LONG2NUM(archive_entry_uid(p->ae));
|
387
|
+
}
|
388
|
+
|
389
|
+
/* */
|
390
|
+
static VALUE rb_libarchive_entry_uname(VALUE self) {
|
391
|
+
struct rb_libarchive_entry_container *p;
|
392
|
+
const char *uname;
|
393
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
394
|
+
Check_Entry(p);
|
395
|
+
uname = archive_entry_uname(p->ae);
|
396
|
+
return (uname != NULL) ? rb_str_new2(uname) : Qnil;
|
397
|
+
}
|
398
|
+
|
399
|
+
/* */
|
400
|
+
static VALUE rb_libarchive_entry_set_atime(VALUE self, VALUE v_time) {
|
401
|
+
struct rb_libarchive_entry_container *p;
|
402
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
403
|
+
Check_Entry(p);
|
404
|
+
Check_Class(v_time, rb_cTime);
|
405
|
+
archive_entry_set_atime(p->ae, TIME2LONG(v_time), 0);
|
406
|
+
return Qnil;
|
407
|
+
}
|
408
|
+
|
409
|
+
/* */
|
410
|
+
static VALUE rb_libarchive_entry_set_atime2(VALUE self, VALUE v_time, VALUE v_ns) {
|
411
|
+
struct rb_libarchive_entry_container *p;
|
412
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
413
|
+
Check_Entry(p);
|
414
|
+
Check_Class(v_time, rb_cTime);
|
415
|
+
Check_Type(v_ns, T_FIXNUM);
|
416
|
+
archive_entry_set_atime(p->ae, TIME2LONG(v_time), NUM2LONG(v_ns));
|
417
|
+
return Qnil;
|
418
|
+
}
|
419
|
+
|
420
|
+
/* */
|
421
|
+
static VALUE rb_libarchive_entry_unset_atime(VALUE self) {
|
422
|
+
struct rb_libarchive_entry_container *p;
|
423
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
424
|
+
Check_Entry(p);
|
425
|
+
archive_entry_unset_atime(p->ae);
|
426
|
+
return Qnil;
|
427
|
+
}
|
428
|
+
|
429
|
+
/* */
|
430
|
+
static VALUE rb_libarchive_entry_set_birthtime(VALUE self, VALUE v_time) {
|
431
|
+
struct rb_libarchive_entry_container *p;
|
432
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
433
|
+
Check_Entry(p);
|
434
|
+
Check_Class(v_time, rb_cTime);
|
435
|
+
archive_entry_set_birthtime(p->ae, TIME2LONG(v_time), 0);
|
436
|
+
return Qnil;
|
437
|
+
}
|
438
|
+
|
439
|
+
/* */
|
440
|
+
static VALUE rb_libarchive_entry_set_birthtime2(VALUE self, VALUE v_time, VALUE v_ns) {
|
441
|
+
struct rb_libarchive_entry_container *p;
|
442
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
443
|
+
Check_Entry(p);
|
444
|
+
Check_Class(v_time, rb_cTime);
|
445
|
+
Check_Type(v_ns, T_FIXNUM);
|
446
|
+
archive_entry_set_birthtime(p->ae, TIME2LONG(v_time), NUM2LONG(v_ns));
|
447
|
+
return Qnil;
|
448
|
+
}
|
449
|
+
|
450
|
+
/* */
|
451
|
+
static VALUE rb_libarchive_entry_unset_birthtime(VALUE self) {
|
452
|
+
struct rb_libarchive_entry_container *p;
|
453
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
454
|
+
Check_Entry(p);
|
455
|
+
archive_entry_unset_birthtime(p->ae);
|
456
|
+
return Qnil;
|
457
|
+
}
|
458
|
+
|
459
|
+
/* */
|
460
|
+
static VALUE rb_libarchive_entry_set_ctime(VALUE self, VALUE v_time) {
|
461
|
+
struct rb_libarchive_entry_container *p;
|
462
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
463
|
+
Check_Entry(p);
|
464
|
+
Check_Class(v_time, rb_cTime);
|
465
|
+
archive_entry_set_ctime(p->ae, TIME2LONG(v_time), 0);
|
466
|
+
return Qnil;
|
467
|
+
}
|
468
|
+
|
469
|
+
/* */
|
470
|
+
static VALUE rb_libarchive_entry_set_ctime2(VALUE self, VALUE v_time, VALUE v_ns) {
|
471
|
+
struct rb_libarchive_entry_container *p;
|
472
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
473
|
+
Check_Entry(p);
|
474
|
+
Check_Class(v_time, rb_cTime);
|
475
|
+
Check_Type(v_ns, T_FIXNUM);
|
476
|
+
archive_entry_set_ctime(p->ae, TIME2LONG(v_time), NUM2LONG(v_ns));
|
477
|
+
return Qnil;
|
478
|
+
}
|
479
|
+
|
480
|
+
/* */
|
481
|
+
static VALUE rb_libarchive_entry_unset_ctime(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
|
+
archive_entry_unset_ctime(p->ae);
|
486
|
+
return Qnil;
|
487
|
+
}
|
488
|
+
|
489
|
+
/* */
|
490
|
+
static VALUE rb_libarchive_entry_set_dev(VALUE self, VALUE v_dev) {
|
491
|
+
struct rb_libarchive_entry_container *p;
|
492
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
493
|
+
Check_Entry(p);
|
494
|
+
Check_Type(v_dev, T_FIXNUM);
|
495
|
+
archive_entry_set_dev(p->ae, NUM2LONG(v_dev));
|
496
|
+
return Qnil;
|
497
|
+
}
|
498
|
+
|
499
|
+
/* */
|
500
|
+
static VALUE rb_libarchive_entry_set_devmajor(VALUE self, VALUE v_dev) {
|
501
|
+
struct rb_libarchive_entry_container *p;
|
502
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
503
|
+
Check_Entry(p);
|
504
|
+
Check_Type(v_dev, T_FIXNUM);
|
505
|
+
archive_entry_set_devmajor(p->ae, NUM2LONG(v_dev));
|
506
|
+
return Qnil;
|
507
|
+
}
|
508
|
+
|
509
|
+
/* */
|
510
|
+
static VALUE rb_libarchive_entry_set_devminor(VALUE self, VALUE v_dev) {
|
511
|
+
struct rb_libarchive_entry_container *p;
|
512
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
513
|
+
Check_Entry(p);
|
514
|
+
Check_Type(v_dev, T_FIXNUM);
|
515
|
+
archive_entry_set_devminor(p->ae, NUM2LONG(v_dev));
|
516
|
+
return Qnil;
|
517
|
+
}
|
518
|
+
|
519
|
+
/* */
|
520
|
+
static VALUE rb_libarchive_entry_set_filetype(VALUE self, VALUE v_type) {
|
521
|
+
struct rb_libarchive_entry_container *p;
|
522
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
523
|
+
Check_Entry(p);
|
524
|
+
Check_Type(v_type, T_FIXNUM);
|
525
|
+
archive_entry_set_filetype(p->ae, NUM2LONG(v_type));
|
526
|
+
return Qnil;
|
527
|
+
}
|
528
|
+
|
529
|
+
/* */
|
530
|
+
static VALUE rb_libarchive_entry_set_fflags(VALUE self, VALUE v_set, VALUE v_clear) {
|
531
|
+
struct rb_libarchive_entry_container *p;
|
532
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
533
|
+
Check_Entry(p);
|
534
|
+
Check_Type(v_set, T_FIXNUM);
|
535
|
+
Check_Type(v_clear, T_FIXNUM);
|
536
|
+
archive_entry_set_fflags(p->ae, (unsigned long) NUM2LONG(v_set), (unsigned long) NUM2LONG(v_clear));
|
537
|
+
return Qnil;
|
538
|
+
}
|
539
|
+
|
540
|
+
/* */
|
541
|
+
static VALUE rb_libarchive_entry_copy_fflags_text(VALUE self, VALUE v_fflags_text) {
|
542
|
+
struct rb_libarchive_entry_container *p;
|
543
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
544
|
+
Check_Entry(p);
|
545
|
+
Check_Type(v_fflags_text, T_STRING);
|
546
|
+
archive_entry_copy_fflags_text(p->ae, RSTRING_PTR(v_fflags_text));
|
547
|
+
return Qnil;
|
548
|
+
}
|
549
|
+
|
550
|
+
/* */
|
551
|
+
static VALUE rb_libarchive_entry_set_gid(VALUE self, VALUE v_gid) {
|
552
|
+
struct rb_libarchive_entry_container *p;
|
553
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
554
|
+
Check_Entry(p);
|
555
|
+
Check_Type(v_gid, T_FIXNUM);
|
556
|
+
archive_entry_set_gid(p->ae, NUM2INT(v_gid));
|
557
|
+
return Qnil;
|
558
|
+
}
|
559
|
+
|
560
|
+
/* */
|
561
|
+
static VALUE rb_libarchive_entry_set_gname(VALUE self, VALUE v_gname) {
|
562
|
+
struct rb_libarchive_entry_container *p;
|
563
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
564
|
+
Check_Entry(p);
|
565
|
+
Check_Type(v_gname, T_STRING);
|
566
|
+
archive_entry_set_gname(p->ae, RSTRING_PTR(v_gname));
|
567
|
+
return Qnil;
|
568
|
+
}
|
569
|
+
|
570
|
+
/* */
|
571
|
+
static VALUE rb_libarchive_entry_copy_gname(VALUE self, VALUE v_gname) {
|
572
|
+
struct rb_libarchive_entry_container *p;
|
573
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
574
|
+
Check_Entry(p);
|
575
|
+
Check_Type(v_gname, T_STRING);
|
576
|
+
archive_entry_copy_gname(p->ae, RSTRING_PTR(v_gname));
|
577
|
+
return Qnil;
|
578
|
+
}
|
579
|
+
|
580
|
+
/* */
|
581
|
+
static VALUE rb_libarchive_entry_set_hardlink(VALUE self, VALUE v_hardlink) {
|
582
|
+
struct rb_libarchive_entry_container *p;
|
583
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
584
|
+
Check_Entry(p);
|
585
|
+
Check_Type(v_hardlink, T_STRING);
|
586
|
+
archive_entry_set_hardlink(p->ae, RSTRING_PTR(v_hardlink));
|
587
|
+
return Qnil;
|
588
|
+
}
|
589
|
+
|
590
|
+
/* */
|
591
|
+
static VALUE rb_libarchive_entry_copy_hardlink(VALUE self, VALUE v_hardlink) {
|
592
|
+
struct rb_libarchive_entry_container *p;
|
593
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
594
|
+
Check_Entry(p);
|
595
|
+
Check_Type(v_hardlink, T_STRING);
|
596
|
+
archive_entry_copy_hardlink(p->ae, RSTRING_PTR(v_hardlink));
|
597
|
+
return Qnil;
|
598
|
+
}
|
599
|
+
|
600
|
+
/* */
|
601
|
+
static VALUE rb_libarchive_entry_set_ino(VALUE self, VALUE v_ino) {
|
602
|
+
struct rb_libarchive_entry_container *p;
|
603
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
604
|
+
Check_Entry(p);
|
605
|
+
Check_Type(v_ino, T_FIXNUM);
|
606
|
+
archive_entry_set_ino(p->ae, (unsigned long) NUM2LONG(v_ino));
|
607
|
+
return Qnil;
|
608
|
+
}
|
609
|
+
|
610
|
+
/* */
|
611
|
+
static VALUE rb_libarchive_entry_set_link(VALUE self, VALUE v_link) {
|
612
|
+
struct rb_libarchive_entry_container *p;
|
613
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
614
|
+
Check_Entry(p);
|
615
|
+
Check_Type(v_link, T_STRING);
|
616
|
+
archive_entry_set_link(p->ae, RSTRING_PTR(v_link));
|
617
|
+
return Qnil;
|
618
|
+
}
|
619
|
+
|
620
|
+
/* */
|
621
|
+
static VALUE rb_libarchive_entry_copy_link(VALUE self, VALUE v_link) {
|
622
|
+
struct rb_libarchive_entry_container *p;
|
623
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
624
|
+
Check_Entry(p);
|
625
|
+
Check_Type(v_link, T_STRING);
|
626
|
+
archive_entry_copy_link(p->ae, RSTRING_PTR(v_link));
|
627
|
+
return Qnil;
|
628
|
+
}
|
629
|
+
|
630
|
+
/* */
|
631
|
+
static VALUE rb_libarchive_entry_set_mode(VALUE self, VALUE v_mode) {
|
632
|
+
struct rb_libarchive_entry_container *p;
|
633
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
634
|
+
Check_Entry(p);
|
635
|
+
Check_Type(v_mode, T_FIXNUM);
|
636
|
+
archive_entry_set_mode(p->ae, NUM2INT(v_mode));
|
637
|
+
return Qnil;
|
638
|
+
}
|
639
|
+
|
640
|
+
/* */
|
641
|
+
static VALUE rb_libarchive_entry_set_mtime(VALUE self, VALUE v_time) {
|
642
|
+
struct rb_libarchive_entry_container *p;
|
643
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
644
|
+
Check_Entry(p);
|
645
|
+
Check_Class(v_time, rb_cTime);
|
646
|
+
archive_entry_set_mtime(p->ae, TIME2LONG(v_time), 0);
|
647
|
+
return Qnil;
|
648
|
+
}
|
649
|
+
|
650
|
+
/* */
|
651
|
+
static VALUE rb_libarchive_entry_set_mtime2(VALUE self, VALUE v_time, VALUE v_ns) {
|
652
|
+
struct rb_libarchive_entry_container *p;
|
653
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
654
|
+
Check_Entry(p);
|
655
|
+
Check_Class(v_time, rb_cTime);
|
656
|
+
Check_Type(v_ns, T_FIXNUM);
|
657
|
+
archive_entry_set_mtime(p->ae, TIME2LONG(v_time), NUM2LONG(v_ns));
|
658
|
+
return Qnil;
|
659
|
+
}
|
660
|
+
|
661
|
+
/* */
|
662
|
+
static VALUE rb_libarchive_entry_unset_mtime(VALUE self) {
|
663
|
+
struct rb_libarchive_entry_container *p;
|
664
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
665
|
+
Check_Entry(p);
|
666
|
+
archive_entry_unset_mtime(p->ae);
|
667
|
+
return Qnil;
|
668
|
+
}
|
669
|
+
|
670
|
+
/* */
|
671
|
+
static VALUE rb_libarchive_entry_set_nlink(VALUE self, VALUE v_nlink) {
|
672
|
+
struct rb_libarchive_entry_container *p;
|
673
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
674
|
+
Check_Entry(p);
|
675
|
+
Check_Type(v_nlink, T_FIXNUM);
|
676
|
+
archive_entry_set_nlink(p->ae, NUM2LONG(v_nlink));
|
677
|
+
return Qnil;
|
678
|
+
}
|
679
|
+
|
680
|
+
/* */
|
681
|
+
static VALUE rb_libarchive_entry_set_pathname(VALUE self, VALUE v_filename) {
|
682
|
+
struct rb_libarchive_entry_container *p;
|
683
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
684
|
+
Check_Entry(p);
|
685
|
+
Check_Type(v_filename, T_STRING);
|
686
|
+
archive_entry_set_pathname(p->ae, RSTRING_PTR(v_filename));
|
687
|
+
return Qnil;
|
688
|
+
}
|
689
|
+
|
690
|
+
/* */
|
691
|
+
static VALUE rb_libarchive_entry_copy_pathname(VALUE self, VALUE v_filename) {
|
692
|
+
struct rb_libarchive_entry_container *p;
|
693
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
694
|
+
Check_Entry(p);
|
695
|
+
Check_Type(v_filename, T_STRING);
|
696
|
+
archive_entry_copy_pathname(p->ae, RSTRING_PTR(v_filename));
|
697
|
+
return Qnil;
|
698
|
+
}
|
699
|
+
|
700
|
+
/* */
|
701
|
+
static VALUE rb_libarchive_entry_set_perm(VALUE self, VALUE v_perm) {
|
702
|
+
struct rb_libarchive_entry_container *p;
|
703
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
704
|
+
Check_Entry(p);
|
705
|
+
Check_Type(v_perm, T_FIXNUM);
|
706
|
+
archive_entry_set_perm(p->ae, NUM2INT(v_perm));
|
707
|
+
return Qnil;
|
708
|
+
}
|
709
|
+
|
710
|
+
/* */
|
711
|
+
static VALUE rb_libarchive_entry_set_rdev(VALUE self, VALUE v_rdev) {
|
712
|
+
struct rb_libarchive_entry_container *p;
|
713
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
714
|
+
Check_Entry(p);
|
715
|
+
Check_Type(v_rdev, T_FIXNUM);
|
716
|
+
archive_entry_set_rdev(p->ae, NUM2LONG(v_rdev));
|
717
|
+
return Qnil;
|
718
|
+
}
|
719
|
+
|
720
|
+
/* */
|
721
|
+
static VALUE rb_libarchive_entry_set_rdevmajor(VALUE self, VALUE v_rdev) {
|
722
|
+
struct rb_libarchive_entry_container *p;
|
723
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
724
|
+
Check_Entry(p);
|
725
|
+
Check_Type(v_rdev, T_FIXNUM);
|
726
|
+
archive_entry_set_rdevmajor(p->ae, NUM2LONG(v_rdev));
|
727
|
+
return Qnil;
|
728
|
+
}
|
729
|
+
|
730
|
+
/* */
|
731
|
+
static VALUE rb_libarchive_entry_set_rdevminor(VALUE self, VALUE v_rdev) {
|
732
|
+
struct rb_libarchive_entry_container *p;
|
733
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
734
|
+
Check_Entry(p);
|
735
|
+
Check_Type(v_rdev, T_FIXNUM);
|
736
|
+
archive_entry_set_rdevminor(p->ae, NUM2LONG(v_rdev));
|
737
|
+
return Qnil;
|
738
|
+
}
|
739
|
+
|
740
|
+
/* */
|
741
|
+
static VALUE rb_libarchive_entry_set_size(VALUE self, VALUE v_size) {
|
742
|
+
struct rb_libarchive_entry_container *p;
|
743
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
744
|
+
Check_Entry(p);
|
745
|
+
Check_Type(v_size, T_FIXNUM);
|
746
|
+
archive_entry_set_size(p->ae, NUM2LONG(v_size));
|
747
|
+
return Qnil;
|
748
|
+
}
|
749
|
+
|
750
|
+
/* */
|
751
|
+
static VALUE rb_libarchive_entry_unset_size(VALUE self) {
|
752
|
+
struct rb_libarchive_entry_container *p;
|
753
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
754
|
+
Check_Entry(p);
|
755
|
+
archive_entry_unset_size(p->ae);
|
756
|
+
return Qnil;
|
757
|
+
}
|
758
|
+
|
759
|
+
#if ARCHIVE_VERSION_NUMBER >= 2005003
|
760
|
+
/* */
|
761
|
+
static VALUE rb_libarchive_entry_copy_sourcepath(VALUE self, VALUE v_sourcepath) {
|
762
|
+
struct rb_libarchive_entry_container *p;
|
763
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
764
|
+
Check_Entry(p);
|
765
|
+
Check_Type(v_sourcepath, T_STRING);
|
766
|
+
archive_entry_copy_sourcepath(p->ae, RSTRING_PTR(v_sourcepath));
|
767
|
+
return Qnil;
|
768
|
+
}
|
769
|
+
#endif
|
770
|
+
|
771
|
+
/* */
|
772
|
+
static VALUE rb_libarchive_entry_set_symlink(VALUE self, VALUE v_symlink) {
|
773
|
+
struct rb_libarchive_entry_container *p;
|
774
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
775
|
+
Check_Entry(p);
|
776
|
+
Check_Type(v_symlink, T_STRING);
|
777
|
+
archive_entry_set_symlink(p->ae, RSTRING_PTR(v_symlink));
|
778
|
+
return Qnil;
|
779
|
+
}
|
780
|
+
|
781
|
+
/* */
|
782
|
+
static VALUE rb_libarchive_entry_copy_symlink(VALUE self, VALUE v_symlink) {
|
783
|
+
struct rb_libarchive_entry_container *p;
|
784
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
785
|
+
Check_Entry(p);
|
786
|
+
Check_Type(v_symlink, T_STRING);
|
787
|
+
archive_entry_copy_symlink(p->ae, RSTRING_PTR(v_symlink));
|
788
|
+
return Qnil;
|
789
|
+
}
|
790
|
+
|
791
|
+
/* */
|
792
|
+
static VALUE rb_libarchive_entry_set_uid(VALUE self, VALUE v_uid) {
|
793
|
+
struct rb_libarchive_entry_container *p;
|
794
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
795
|
+
Check_Entry(p);
|
796
|
+
Check_Type(v_uid, T_FIXNUM);
|
797
|
+
archive_entry_set_uid(p->ae, NUM2INT(v_uid));
|
798
|
+
return Qnil;
|
799
|
+
}
|
800
|
+
|
801
|
+
/* */
|
802
|
+
static VALUE rb_libarchive_entry_set_uname(VALUE self, VALUE v_uname) {
|
803
|
+
struct rb_libarchive_entry_container *p;
|
804
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
805
|
+
Check_Entry(p);
|
806
|
+
Check_Type(v_uname, T_STRING);
|
807
|
+
archive_entry_set_uname(p->ae, RSTRING_PTR(v_uname));
|
808
|
+
return Qnil;
|
809
|
+
}
|
810
|
+
|
811
|
+
/* */
|
812
|
+
static VALUE rb_libarchive_entry_copy_uname(VALUE self, VALUE v_uname) {
|
813
|
+
struct rb_libarchive_entry_container *p;
|
814
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
815
|
+
Check_Entry(p);
|
816
|
+
Check_Type(v_uname, T_STRING);
|
817
|
+
archive_entry_copy_uname(p->ae, RSTRING_PTR(v_uname));
|
818
|
+
return Qnil;
|
819
|
+
}
|
820
|
+
|
821
|
+
/* */
|
822
|
+
static VALUE rb_libarchive_entry_copy_stat(VALUE self, VALUE v_filename) {
|
823
|
+
struct rb_libarchive_entry_container *p;
|
824
|
+
const char *filename;
|
825
|
+
struct stat s;
|
826
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
827
|
+
Check_Entry(p);
|
828
|
+
Check_Type(v_filename, T_STRING);
|
829
|
+
filename = RSTRING_PTR(v_filename);
|
830
|
+
|
831
|
+
if (stat(filename, &s) != 0) {
|
832
|
+
rb_raise(rb_eArchiveError, "Copy stat failed: %", strerror(errno));
|
833
|
+
}
|
834
|
+
|
835
|
+
archive_entry_copy_stat(p->ae, &s);
|
836
|
+
return Qnil;
|
837
|
+
}
|
838
|
+
|
839
|
+
/* */
|
840
|
+
static VALUE rb_libarchive_entry_copy_lstat(VALUE self, VALUE v_filename) {
|
841
|
+
struct rb_libarchive_entry_container *p;
|
842
|
+
const char *filename;
|
843
|
+
struct stat s;
|
844
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
845
|
+
Check_Entry(p);
|
846
|
+
Check_Type(v_filename, T_STRING);
|
847
|
+
filename = RSTRING_PTR(v_filename);
|
848
|
+
|
849
|
+
if (lstat(filename, &s) != 0) {
|
850
|
+
rb_raise(rb_eArchiveError, "Copy stat failed: %", strerror(errno));
|
851
|
+
}
|
852
|
+
|
853
|
+
archive_entry_copy_stat(p->ae, &s);
|
854
|
+
return Qnil;
|
855
|
+
}
|
856
|
+
|
857
|
+
/* */
|
858
|
+
static VALUE rb_libarchive_entry_xattr_clear(VALUE self) {
|
859
|
+
struct rb_libarchive_entry_container *p;
|
860
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
861
|
+
Check_Entry(p);
|
862
|
+
archive_entry_xattr_clear(p->ae);
|
863
|
+
return Qnil;
|
864
|
+
}
|
865
|
+
|
866
|
+
/* */
|
867
|
+
static VALUE rb_libarchive_entry_xattr_add_entry(VALUE self, VALUE v_name, VALUE v_value) {
|
868
|
+
struct rb_libarchive_entry_container *p;
|
869
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
870
|
+
Check_Entry(p);
|
871
|
+
Check_Type(v_name, T_STRING);
|
872
|
+
Check_Type(v_value, T_STRING);
|
873
|
+
archive_entry_xattr_add_entry(p->ae, RSTRING_PTR(v_name), RSTRING_PTR(v_value), RSTRING_LEN(v_value));
|
874
|
+
return Qnil;
|
875
|
+
}
|
876
|
+
|
877
|
+
/* */
|
878
|
+
static VALUE rb_libarchive_entry_xattr_count(VALUE self) {
|
879
|
+
struct rb_libarchive_entry_container *p;
|
880
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
881
|
+
Check_Entry(p);
|
882
|
+
return INT2NUM(archive_entry_xattr_count(p->ae));
|
883
|
+
}
|
884
|
+
|
885
|
+
/* */
|
886
|
+
static VALUE rb_libarchive_entry_xattr_reset(VALUE self) {
|
887
|
+
struct rb_libarchive_entry_container *p;
|
888
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
889
|
+
Check_Entry(p);
|
890
|
+
return INT2NUM(archive_entry_xattr_reset(p->ae));
|
891
|
+
}
|
892
|
+
|
893
|
+
/* */
|
894
|
+
static VALUE rb_libarchive_entry_xattr_next(VALUE self) {
|
895
|
+
struct rb_libarchive_entry_container *p;
|
896
|
+
const char *name;
|
897
|
+
const void *value;
|
898
|
+
size_t size;
|
899
|
+
Data_Get_Struct(self, struct rb_libarchive_entry_container, p);
|
900
|
+
Check_Entry(p);
|
901
|
+
|
902
|
+
if (archive_entry_xattr_next(p->ae, &name, &value, &size) != ARCHIVE_OK) {
|
903
|
+
return Qnil;
|
904
|
+
} else {
|
905
|
+
return rb_ary_new3(3, rb_str_new2(name), rb_str_new(value, size));
|
906
|
+
}
|
907
|
+
}
|
908
|
+
|
909
|
+
void Init_libarchive_entry() {
|
910
|
+
rb_cArchiveEntry = rb_define_class_under(rb_mArchive, "Entry", rb_cObject);
|
911
|
+
rb_define_alloc_func(rb_cArchiveEntry, rb_libarchive_entry_alloc);
|
912
|
+
rb_funcall(rb_cArchiveEntry, rb_intern("private_class_method"), 1, ID2SYM(rb_intern("new")));
|
913
|
+
rb_define_method(rb_cArchiveEntry, "close", rb_libarchive_entry_close, 0);
|
914
|
+
|
915
|
+
rb_define_method(rb_cArchiveEntry, "atime", rb_libarchive_entry_atime, 0);
|
916
|
+
rb_define_method(rb_cArchiveEntry, "atime_nsec", rb_libarchive_entry_atime_nsec, 0);
|
917
|
+
rb_define_method(rb_cArchiveEntry, "atime_is_set?", rb_libarchive_entry_atime_is_set, 0);
|
918
|
+
rb_define_method(rb_cArchiveEntry, "birthtime", rb_libarchive_entry_birthtime, 0);
|
919
|
+
rb_define_method(rb_cArchiveEntry, "birthtime_nsec", rb_libarchive_entry_birthtime_nsec, 0);
|
920
|
+
rb_define_method(rb_cArchiveEntry, "birthtime_is_set?", rb_libarchive_entry_birthtime_is_set, 0);
|
921
|
+
rb_define_method(rb_cArchiveEntry, "ctime", rb_libarchive_entry_ctime, 0);
|
922
|
+
rb_define_method(rb_cArchiveEntry, "ctime_nsec", rb_libarchive_entry_ctime_nsec, 0);
|
923
|
+
rb_define_method(rb_cArchiveEntry, "ctime_is_set?", rb_libarchive_entry_ctime_is_set, 0);
|
924
|
+
rb_define_method(rb_cArchiveEntry, "dev", rb_libarchive_entry_dev, 0);
|
925
|
+
rb_define_method(rb_cArchiveEntry, "devmajor", rb_libarchive_entry_devmajor, 0);
|
926
|
+
rb_define_method(rb_cArchiveEntry, "devminor", rb_libarchive_entry_devminor, 0);
|
927
|
+
rb_define_method(rb_cArchiveEntry, "filetype", rb_libarchive_entry_filetype, 0);
|
928
|
+
rb_define_method(rb_cArchiveEntry, "directory?", rb_libarchive_entry_is_directory, 0);
|
929
|
+
rb_define_method(rb_cArchiveEntry, "character_special?", rb_libarchive_entry_is_character_special, 0);
|
930
|
+
rb_define_method(rb_cArchiveEntry, "block_special?", rb_libarchive_entry_is_block_special, 0);
|
931
|
+
rb_define_method(rb_cArchiveEntry, "regular?", rb_libarchive_entry_is_regular, 0);
|
932
|
+
rb_define_method(rb_cArchiveEntry, "symbolic_link?", rb_libarchive_entry_is_symbolic_link, 0);
|
933
|
+
rb_define_method(rb_cArchiveEntry, "socket?", rb_libarchive_entry_is_socket, 0);
|
934
|
+
rb_define_method(rb_cArchiveEntry, "fifo?", rb_libarchive_entry_is_fifo, 0);
|
935
|
+
rb_define_method(rb_cArchiveEntry, "fflags", rb_libarchive_entry_fflags, 0);
|
936
|
+
rb_define_method(rb_cArchiveEntry, "fflags_text", rb_libarchive_entry_fflags_text, 0);
|
937
|
+
rb_define_method(rb_cArchiveEntry, "gid", rb_libarchive_entry_gid, 0);
|
938
|
+
rb_define_method(rb_cArchiveEntry, "gname", rb_libarchive_entry_gname, 0);
|
939
|
+
rb_define_method(rb_cArchiveEntry, "hardlink", rb_libarchive_entry_hardlink, 0);
|
940
|
+
rb_define_method(rb_cArchiveEntry, "ino", rb_libarchive_entry_ino, 0);
|
941
|
+
rb_define_method(rb_cArchiveEntry, "mode", rb_libarchive_entry_mode, 0);
|
942
|
+
rb_define_method(rb_cArchiveEntry, "mtime", rb_libarchive_entry_mtime, 0);
|
943
|
+
rb_define_method(rb_cArchiveEntry, "mtime_nsec", rb_libarchive_entry_mtime_nsec, 0);
|
944
|
+
rb_define_method(rb_cArchiveEntry, "mtime_is_set?", rb_libarchive_entry_mtime_is_set, 0);
|
945
|
+
rb_define_method(rb_cArchiveEntry, "nlink", rb_libarchive_entry_nlink, 0);
|
946
|
+
rb_define_method(rb_cArchiveEntry, "pathname", rb_libarchive_entry_pathname, 0);
|
947
|
+
rb_define_method(rb_cArchiveEntry, "rdev", rb_libarchive_entry_rdev, 0);
|
948
|
+
rb_define_method(rb_cArchiveEntry, "rdevmajor", rb_libarchive_entry_rdevmajor, 0);
|
949
|
+
rb_define_method(rb_cArchiveEntry, "rdevminor", rb_libarchive_entry_rdevminor, 0);
|
950
|
+
#if ARCHIVE_VERSION_NUMBER >= 2005003
|
951
|
+
rb_define_method(rb_cArchiveEntry, "sourcepath", rb_libarchive_entry_sourcepath, 0);
|
952
|
+
#endif
|
953
|
+
rb_define_method(rb_cArchiveEntry, "size", rb_libarchive_entry_size, 0);
|
954
|
+
rb_define_method(rb_cArchiveEntry, "size_is_set?", rb_libarchive_entry_size_is_set, 0);
|
955
|
+
#if ARCHIVE_VERSION_NUMBER >= 2003002
|
956
|
+
rb_define_method(rb_cArchiveEntry, "strmode", rb_libarchive_entry_strmode, 0);
|
957
|
+
#endif
|
958
|
+
rb_define_method(rb_cArchiveEntry, "symlink", rb_libarchive_entry_symlink, 0);
|
959
|
+
rb_define_method(rb_cArchiveEntry, "uid", rb_libarchive_entry_uid, 0);
|
960
|
+
rb_define_method(rb_cArchiveEntry, "uname", rb_libarchive_entry_uname, 0);
|
961
|
+
|
962
|
+
rb_define_method(rb_cArchiveEntry, "atime=", rb_libarchive_entry_set_atime, 1);
|
963
|
+
rb_define_method(rb_cArchiveEntry, "set_atime", rb_libarchive_entry_set_atime2, 2);
|
964
|
+
rb_define_method(rb_cArchiveEntry, "unset_atime", rb_libarchive_entry_unset_atime, 0);
|
965
|
+
rb_define_method(rb_cArchiveEntry, "birthtimee=", rb_libarchive_entry_set_birthtime, 1);
|
966
|
+
rb_define_method(rb_cArchiveEntry, "set_birthtime", rb_libarchive_entry_set_birthtime2, 2);
|
967
|
+
rb_define_method(rb_cArchiveEntry, "unset_birthtime", rb_libarchive_entry_unset_birthtime, 0);
|
968
|
+
rb_define_method(rb_cArchiveEntry, "ctime=", rb_libarchive_entry_set_ctime, 1);
|
969
|
+
rb_define_method(rb_cArchiveEntry, "set_ctime", rb_libarchive_entry_set_ctime2, 2);
|
970
|
+
rb_define_method(rb_cArchiveEntry, "unset_ctime", rb_libarchive_entry_unset_ctime, 0);
|
971
|
+
rb_define_method(rb_cArchiveEntry, "dev=", rb_libarchive_entry_set_dev, 1);
|
972
|
+
rb_define_method(rb_cArchiveEntry, "devmajor=", rb_libarchive_entry_set_devmajor, 1);
|
973
|
+
rb_define_method(rb_cArchiveEntry, "devminor=", rb_libarchive_entry_set_devminor, 1);
|
974
|
+
rb_define_method(rb_cArchiveEntry, "filetype=", rb_libarchive_entry_set_filetype, 1);
|
975
|
+
rb_define_method(rb_cArchiveEntry, "set_fflags", rb_libarchive_entry_set_fflags, 2);
|
976
|
+
rb_define_method(rb_cArchiveEntry, "copy_fflags_text", rb_libarchive_entry_copy_fflags_text, 1);
|
977
|
+
rb_define_method(rb_cArchiveEntry, "gid=", rb_libarchive_entry_set_gid, 1);
|
978
|
+
rb_define_method(rb_cArchiveEntry, "gname=", rb_libarchive_entry_set_gname, 1);
|
979
|
+
rb_define_method(rb_cArchiveEntry, "copy_gname", rb_libarchive_entry_copy_gname, 1);
|
980
|
+
rb_define_method(rb_cArchiveEntry, "hardlink=", rb_libarchive_entry_set_hardlink, 1);
|
981
|
+
rb_define_method(rb_cArchiveEntry, "copy_hardlink", rb_libarchive_entry_copy_hardlink, 1);
|
982
|
+
rb_define_method(rb_cArchiveEntry, "ino=", rb_libarchive_entry_set_ino, 1);
|
983
|
+
rb_define_method(rb_cArchiveEntry, "link=", rb_libarchive_entry_set_link, 1);
|
984
|
+
rb_define_method(rb_cArchiveEntry, "copy_link", rb_libarchive_entry_copy_link, 1);
|
985
|
+
rb_define_method(rb_cArchiveEntry, "mode=", rb_libarchive_entry_set_mode, 1);
|
986
|
+
rb_define_method(rb_cArchiveEntry, "mtime=", rb_libarchive_entry_set_mtime, 1);
|
987
|
+
rb_define_method(rb_cArchiveEntry, "set_mtime", rb_libarchive_entry_set_mtime2, 2);
|
988
|
+
rb_define_method(rb_cArchiveEntry, "unset_mtime", rb_libarchive_entry_unset_mtime, 0);
|
989
|
+
rb_define_method(rb_cArchiveEntry, "nlink=", rb_libarchive_entry_set_nlink, 1);
|
990
|
+
rb_define_method(rb_cArchiveEntry, "pathname=", rb_libarchive_entry_set_pathname, 1);
|
991
|
+
rb_define_method(rb_cArchiveEntry, "copy_pathname", rb_libarchive_entry_copy_pathname, 1);
|
992
|
+
rb_define_method(rb_cArchiveEntry, "perm=", rb_libarchive_entry_set_perm, 1);
|
993
|
+
rb_define_method(rb_cArchiveEntry, "rdev=", rb_libarchive_entry_set_rdev, 1);
|
994
|
+
rb_define_method(rb_cArchiveEntry, "rdevmajor=", rb_libarchive_entry_set_rdevmajor, 1);
|
995
|
+
rb_define_method(rb_cArchiveEntry, "rdevminor=", rb_libarchive_entry_set_rdevminor, 1);
|
996
|
+
rb_define_method(rb_cArchiveEntry, "size=", rb_libarchive_entry_set_size, 1);
|
997
|
+
rb_define_method(rb_cArchiveEntry, "unset_size", rb_libarchive_entry_unset_size, 0);
|
998
|
+
#if ARCHIVE_VERSION_NUMBER >= 2005003
|
999
|
+
rb_define_method(rb_cArchiveEntry, "copy_sourcepath", rb_libarchive_entry_copy_sourcepath, 1);
|
1000
|
+
#endif
|
1001
|
+
rb_define_method(rb_cArchiveEntry, "symlink=", rb_libarchive_entry_set_symlink, 1);
|
1002
|
+
rb_define_method(rb_cArchiveEntry, "copy_symlink", rb_libarchive_entry_copy_symlink, 1);
|
1003
|
+
rb_define_method(rb_cArchiveEntry, "uid=", rb_libarchive_entry_set_uid, 1);
|
1004
|
+
rb_define_method(rb_cArchiveEntry, "uname=", rb_libarchive_entry_set_uname, 1);
|
1005
|
+
rb_define_method(rb_cArchiveEntry, "copy_uname", rb_libarchive_entry_copy_uname, 1);
|
1006
|
+
|
1007
|
+
rb_define_method(rb_cArchiveEntry, "copy_stat", rb_libarchive_entry_copy_stat, 1);
|
1008
|
+
rb_define_method(rb_cArchiveEntry, "copy_lstat", rb_libarchive_entry_copy_lstat, 1);
|
1009
|
+
|
1010
|
+
rb_define_method(rb_cArchiveEntry, "xattr_clear", rb_libarchive_entry_xattr_clear, 0);
|
1011
|
+
rb_define_method(rb_cArchiveEntry, "xattr_add_entry", rb_libarchive_entry_xattr_add_entry, 2);
|
1012
|
+
rb_define_method(rb_cArchiveEntry, "xattr_count", rb_libarchive_entry_xattr_count, 0);
|
1013
|
+
rb_define_method(rb_cArchiveEntry, "xattr_reset", rb_libarchive_entry_xattr_reset, 0);
|
1014
|
+
rb_define_method(rb_cArchiveEntry, "xattr_next", rb_libarchive_entry_xattr_next, 0);
|
1015
|
+
}
|