libarchive-ruby 0.0.1.dev
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.
- data/COPYING.txt +339 -0
- data/README.rdoc +135 -0
- data/ext/archive.cpp +1547 -0
- data/ext/entry.cpp +592 -0
- data/ext/extconf.rb +38 -0
- data/ext/main.hpp +86 -0
- metadata +80 -0
data/ext/entry.cpp
ADDED
@@ -0,0 +1,592 @@
|
|
1
|
+
/****************************************************************************
|
2
|
+
This file is part of libarchive-ruby.
|
3
|
+
|
4
|
+
libarchive-ruby is a Ruby binding for the C library libarchive.
|
5
|
+
|
6
|
+
Copyright (C) 2011 Hans Mackowiak
|
7
|
+
|
8
|
+
libarchive-ruby is free software; you can redistribute it and/or modify
|
9
|
+
it under the terms of the GNU General Public License as published by
|
10
|
+
the Free Software Foundation; either version 2 of the License, or
|
11
|
+
(at your option) any later version.
|
12
|
+
|
13
|
+
libarchive-ruby is distributed in the hope that it will be useful,
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
GNU General Public License for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU General Public License along
|
19
|
+
with libarchive-ruby; if not, write to the Free Software Foundation, Inc.,
|
20
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
21
|
+
****************************************************************************/
|
22
|
+
|
23
|
+
#include "main.hpp"
|
24
|
+
|
25
|
+
#define _self wrap<archive_entry*>(self)
|
26
|
+
|
27
|
+
VALUE rb_cArchiveEntry;
|
28
|
+
|
29
|
+
VALUE ArchiveEntry_alloc(VALUE self)
|
30
|
+
{
|
31
|
+
return wrap(archive_entry_new());
|
32
|
+
}
|
33
|
+
|
34
|
+
|
35
|
+
/*
|
36
|
+
* call-seq:
|
37
|
+
* entry.dev -> Integer
|
38
|
+
*
|
39
|
+
* returns dev
|
40
|
+
*/
|
41
|
+
VALUE ArchiveEntry_dev(VALUE self)
|
42
|
+
{
|
43
|
+
return INT2NUM(archive_entry_dev(_self));
|
44
|
+
}
|
45
|
+
/*
|
46
|
+
* call-seq:
|
47
|
+
* entry.devmajor -> Integer
|
48
|
+
*
|
49
|
+
* returns devmajor
|
50
|
+
*/
|
51
|
+
VALUE ArchiveEntry_devmajor(VALUE self)
|
52
|
+
{
|
53
|
+
return INT2NUM(archive_entry_devmajor(_self));
|
54
|
+
}
|
55
|
+
/*
|
56
|
+
* call-seq:
|
57
|
+
* entry.devminor -> Integer
|
58
|
+
*
|
59
|
+
* returns devminor
|
60
|
+
*/
|
61
|
+
VALUE ArchiveEntry_devminor(VALUE self)
|
62
|
+
{
|
63
|
+
return INT2NUM(archive_entry_devminor(_self));
|
64
|
+
}
|
65
|
+
|
66
|
+
/*
|
67
|
+
* call-seq:
|
68
|
+
* entry.rdev -> Integer
|
69
|
+
*
|
70
|
+
* returns rdev
|
71
|
+
*/
|
72
|
+
VALUE ArchiveEntry_rdev(VALUE self)
|
73
|
+
{
|
74
|
+
return INT2NUM(archive_entry_rdev(_self));
|
75
|
+
}
|
76
|
+
/*
|
77
|
+
* call-seq:
|
78
|
+
* entry.rdevmajor -> Integer
|
79
|
+
*
|
80
|
+
* returns rdevmajor
|
81
|
+
*/
|
82
|
+
VALUE ArchiveEntry_rdevmajor(VALUE self)
|
83
|
+
{
|
84
|
+
return INT2NUM(archive_entry_rdevmajor(_self));
|
85
|
+
}
|
86
|
+
/*
|
87
|
+
* call-seq:
|
88
|
+
* entry.rdevminor -> Integer
|
89
|
+
*
|
90
|
+
* returns rdevminor
|
91
|
+
*/
|
92
|
+
VALUE ArchiveEntry_rdevminor(VALUE self)
|
93
|
+
{
|
94
|
+
return INT2NUM(archive_entry_rdevminor(_self));
|
95
|
+
}
|
96
|
+
|
97
|
+
//__LA_DECL __LA_MODE_T archive_entry_filetype(struct archive_entry *);
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
/*
|
103
|
+
* call-seq:
|
104
|
+
* entry.gname -> String
|
105
|
+
*
|
106
|
+
* Get Group Name
|
107
|
+
*/
|
108
|
+
VALUE ArchiveEntry_gname(VALUE self)
|
109
|
+
{
|
110
|
+
return rb_str_new2(archive_entry_gname(_self));
|
111
|
+
}
|
112
|
+
|
113
|
+
/*
|
114
|
+
* call-seq:
|
115
|
+
* entry.uname -> String
|
116
|
+
*
|
117
|
+
* Get User Name
|
118
|
+
*/
|
119
|
+
VALUE ArchiveEntry_uname(VALUE self)
|
120
|
+
{
|
121
|
+
return rb_str_new2(archive_entry_uname(_self));
|
122
|
+
}
|
123
|
+
/*
|
124
|
+
* call-seq:
|
125
|
+
* entry.gid -> Integer
|
126
|
+
*
|
127
|
+
* Get Group ID
|
128
|
+
*/
|
129
|
+
|
130
|
+
VALUE ArchiveEntry_gid(VALUE self)
|
131
|
+
{
|
132
|
+
return INT2NUM(archive_entry_gid(_self));
|
133
|
+
}
|
134
|
+
|
135
|
+
/*
|
136
|
+
* call-seq:
|
137
|
+
* entry.uid -> Integer
|
138
|
+
*
|
139
|
+
* Get User ID
|
140
|
+
*/
|
141
|
+
VALUE ArchiveEntry_uid(VALUE self)
|
142
|
+
{
|
143
|
+
return INT2NUM(archive_entry_uid(_self));
|
144
|
+
}
|
145
|
+
/*
|
146
|
+
* call-seq:
|
147
|
+
* entry.gid = Integer
|
148
|
+
*
|
149
|
+
* Set Group ID
|
150
|
+
*/
|
151
|
+
VALUE ArchiveEntry_set_gid(VALUE self,VALUE id){
|
152
|
+
archive_entry_set_gid(_self,NUM2INT(id));
|
153
|
+
return id;
|
154
|
+
}
|
155
|
+
/*
|
156
|
+
* call-seq:
|
157
|
+
* entry.uid = Integer
|
158
|
+
*
|
159
|
+
* Set User ID
|
160
|
+
*/
|
161
|
+
|
162
|
+
VALUE ArchiveEntry_set_uid(VALUE self,VALUE id){
|
163
|
+
archive_entry_set_uid(_self,NUM2INT(id));
|
164
|
+
return id;
|
165
|
+
}
|
166
|
+
|
167
|
+
/*
|
168
|
+
* call-seq:
|
169
|
+
* entry.gname = String
|
170
|
+
*
|
171
|
+
* Set Group Name
|
172
|
+
*/
|
173
|
+
|
174
|
+
VALUE ArchiveEntry_set_gname(VALUE self,VALUE val)
|
175
|
+
{
|
176
|
+
archive_entry_set_gname(_self,rb_string_value_cstr(&val));
|
177
|
+
return val;
|
178
|
+
}
|
179
|
+
/*
|
180
|
+
* call-seq:
|
181
|
+
* entry.uname = String
|
182
|
+
*
|
183
|
+
* Set User Name
|
184
|
+
*/
|
185
|
+
VALUE ArchiveEntry_set_uname(VALUE self,VALUE val)
|
186
|
+
{
|
187
|
+
archive_entry_set_uname(_self,rb_string_value_cstr(&val));
|
188
|
+
return val;
|
189
|
+
}
|
190
|
+
|
191
|
+
/*
|
192
|
+
* call-seq:
|
193
|
+
* entry.path -> String or nil
|
194
|
+
*
|
195
|
+
* returns the path of the file
|
196
|
+
*/
|
197
|
+
VALUE ArchiveEntry_path(VALUE self)
|
198
|
+
{
|
199
|
+
const char* str = archive_entry_pathname(_self);
|
200
|
+
return str ==NULL? Qnil : rb_str_new2(str);
|
201
|
+
}
|
202
|
+
|
203
|
+
/*
|
204
|
+
* call-seq:
|
205
|
+
* entry.hardlink -> String or nil
|
206
|
+
*
|
207
|
+
* returns the hardlink
|
208
|
+
*/
|
209
|
+
VALUE ArchiveEntry_hardlink(VALUE self)
|
210
|
+
{
|
211
|
+
const char* str = archive_entry_hardlink(_self);
|
212
|
+
return str ==NULL? Qnil : rb_str_new2(str);
|
213
|
+
}
|
214
|
+
|
215
|
+
/*
|
216
|
+
* call-seq:
|
217
|
+
* entry.sourcepath -> String or nil
|
218
|
+
*
|
219
|
+
* returns the hardlink
|
220
|
+
*/
|
221
|
+
VALUE ArchiveEntry_sourcepath(VALUE self)
|
222
|
+
{
|
223
|
+
const char* str = archive_entry_sourcepath(_self);
|
224
|
+
return str ==NULL? Qnil : rb_str_new2(str);
|
225
|
+
}
|
226
|
+
|
227
|
+
/*
|
228
|
+
* call-seq:
|
229
|
+
* entry.strmode -> String or nil
|
230
|
+
*
|
231
|
+
* returns the mode as string
|
232
|
+
*/
|
233
|
+
VALUE ArchiveEntry_strmode(VALUE self)
|
234
|
+
{
|
235
|
+
const char* str = archive_entry_strmode(_self);
|
236
|
+
return str ==NULL? Qnil : rb_str_new2(str);
|
237
|
+
}
|
238
|
+
/*
|
239
|
+
* call-seq:
|
240
|
+
* entry.symlink -> String or nil
|
241
|
+
*
|
242
|
+
* returns the symlink
|
243
|
+
*/
|
244
|
+
VALUE ArchiveEntry_symlink(VALUE self)
|
245
|
+
{
|
246
|
+
const char* str = archive_entry_symlink(_self);
|
247
|
+
return str ==NULL? Qnil : rb_str_new2(str);
|
248
|
+
}
|
249
|
+
/*
|
250
|
+
* call-seq:
|
251
|
+
* entry.path = String
|
252
|
+
*
|
253
|
+
* sets path
|
254
|
+
*/
|
255
|
+
VALUE ArchiveEntry_set_path(VALUE self,VALUE val)
|
256
|
+
{
|
257
|
+
archive_entry_set_pathname(_self,rb_string_value_cstr(&val));
|
258
|
+
return val;
|
259
|
+
}
|
260
|
+
/*
|
261
|
+
* call-seq:
|
262
|
+
* entry.hardlink = String
|
263
|
+
*
|
264
|
+
* sets hardlink
|
265
|
+
*/
|
266
|
+
VALUE ArchiveEntry_set_hardlink(VALUE self,VALUE val)
|
267
|
+
{
|
268
|
+
archive_entry_set_hardlink(_self,rb_string_value_cstr(&val));
|
269
|
+
return val;
|
270
|
+
}
|
271
|
+
/*
|
272
|
+
* call-seq:
|
273
|
+
* entry.symlink = String
|
274
|
+
*
|
275
|
+
* sets symlink
|
276
|
+
*/
|
277
|
+
VALUE ArchiveEntry_set_symlink(VALUE self,VALUE val)
|
278
|
+
{
|
279
|
+
archive_entry_set_symlink(_self,rb_string_value_cstr(&val));
|
280
|
+
return val;
|
281
|
+
}
|
282
|
+
|
283
|
+
/* :nodoc:
|
284
|
+
*/
|
285
|
+
VALUE ArchiveEntry_atime(VALUE self)
|
286
|
+
{
|
287
|
+
if(archive_entry_atime_is_set(_self))
|
288
|
+
return rb_time_new(archive_entry_atime(_self),archive_entry_atime_nsec(_self));
|
289
|
+
else
|
290
|
+
return Qnil;
|
291
|
+
}
|
292
|
+
/*:nodoc:
|
293
|
+
* call-seq:
|
294
|
+
* entry.ctime -> Time or nil
|
295
|
+
*
|
296
|
+
* returns create time
|
297
|
+
*/
|
298
|
+
VALUE ArchiveEntry_ctime(VALUE self)
|
299
|
+
{
|
300
|
+
if(archive_entry_ctime_is_set(_self))
|
301
|
+
return rb_time_new(archive_entry_ctime(_self),archive_entry_ctime_nsec(_self));
|
302
|
+
else
|
303
|
+
return Qnil;
|
304
|
+
}
|
305
|
+
/*:nodoc:
|
306
|
+
* call-seq:
|
307
|
+
* entry.mtime -> Time or nil
|
308
|
+
*
|
309
|
+
* returns modification time
|
310
|
+
*/
|
311
|
+
VALUE ArchiveEntry_mtime(VALUE self)
|
312
|
+
{
|
313
|
+
if(archive_entry_mtime_is_set(_self))
|
314
|
+
return rb_time_new(archive_entry_mtime(_self),archive_entry_mtime_nsec(_self));
|
315
|
+
else
|
316
|
+
return Qnil;
|
317
|
+
}
|
318
|
+
/*:nodoc:
|
319
|
+
* call-seq:
|
320
|
+
* entry.birthtime -> Time or nil
|
321
|
+
*
|
322
|
+
* returns birthtime
|
323
|
+
*/
|
324
|
+
VALUE ArchiveEntry_birthtime(VALUE self)
|
325
|
+
{
|
326
|
+
if(archive_entry_birthtime_is_set(_self))
|
327
|
+
return rb_time_new(archive_entry_birthtime(_self),archive_entry_birthtime_nsec(_self));
|
328
|
+
else
|
329
|
+
return Qnil;
|
330
|
+
}
|
331
|
+
/* :nodoc:
|
332
|
+
*/
|
333
|
+
VALUE ArchiveEntry_set_atime(VALUE self,VALUE value)
|
334
|
+
{
|
335
|
+
if(value ==Qnil)
|
336
|
+
archive_entry_unset_atime(_self);
|
337
|
+
else
|
338
|
+
archive_entry_set_atime(_self,NUM2INT(rb_funcall(value,rb_intern("to_i"),0)),NUM2INT(rb_funcall(value,rb_intern("usec"),0)));
|
339
|
+
return value;
|
340
|
+
}
|
341
|
+
/*:nodoc:
|
342
|
+
* call-seq:
|
343
|
+
* entry.ctime = Time or nil
|
344
|
+
*
|
345
|
+
* sets create time
|
346
|
+
*/
|
347
|
+
VALUE ArchiveEntry_set_ctime(VALUE self,VALUE value)
|
348
|
+
{
|
349
|
+
if(value ==Qnil)
|
350
|
+
archive_entry_unset_ctime(_self);
|
351
|
+
else
|
352
|
+
archive_entry_set_ctime(_self,NUM2INT(rb_funcall(value,rb_intern("to_i"),0)),NUM2INT(rb_funcall(value,rb_intern("usec"),0)));
|
353
|
+
return value;
|
354
|
+
}
|
355
|
+
/*:nodoc:
|
356
|
+
* call-seq:
|
357
|
+
* entry.mtime = Time or nil
|
358
|
+
*
|
359
|
+
* sets modification time
|
360
|
+
*/
|
361
|
+
VALUE ArchiveEntry_set_mtime(VALUE self,VALUE value)
|
362
|
+
{
|
363
|
+
if(value ==Qnil)
|
364
|
+
archive_entry_unset_mtime(_self);
|
365
|
+
else
|
366
|
+
archive_entry_set_mtime(_self,NUM2INT(rb_funcall(value,rb_intern("to_i"),0)),NUM2INT(rb_funcall(value,rb_intern("usec"),0)));
|
367
|
+
return value;
|
368
|
+
}
|
369
|
+
/*:nodoc:
|
370
|
+
* call-seq:
|
371
|
+
* entry.birthtime = Time or nil
|
372
|
+
*
|
373
|
+
* sets birthtime
|
374
|
+
*/
|
375
|
+
VALUE ArchiveEntry_set_birthtime(VALUE self,VALUE value)
|
376
|
+
{
|
377
|
+
if(value ==Qnil)
|
378
|
+
archive_entry_unset_birthtime(_self);
|
379
|
+
else
|
380
|
+
archive_entry_set_birthtime(_self,NUM2INT(rb_funcall(value,rb_intern("to_i"),0)),NUM2INT(rb_funcall(value,rb_intern("usec"),0)));
|
381
|
+
return value;
|
382
|
+
}
|
383
|
+
/*
|
384
|
+
* call-seq:
|
385
|
+
* entry.dev = Integer
|
386
|
+
*
|
387
|
+
* sets dev
|
388
|
+
*/
|
389
|
+
VALUE ArchiveEntry_set_dev(VALUE self,VALUE dev){
|
390
|
+
archive_entry_set_dev(_self,NUM2INT(dev));
|
391
|
+
return dev;
|
392
|
+
}
|
393
|
+
/*
|
394
|
+
* call-seq:
|
395
|
+
* entry.devmajor = Integer
|
396
|
+
*
|
397
|
+
* sets devmajor
|
398
|
+
*/
|
399
|
+
VALUE ArchiveEntry_set_devmajor(VALUE self,VALUE dev){
|
400
|
+
archive_entry_set_devmajor(_self,NUM2INT(dev));
|
401
|
+
return dev;
|
402
|
+
}
|
403
|
+
/*
|
404
|
+
* call-seq:
|
405
|
+
* entry.devminor = Integer
|
406
|
+
*
|
407
|
+
* sets devminor
|
408
|
+
*/
|
409
|
+
VALUE ArchiveEntry_set_devminor(VALUE self,VALUE dev){
|
410
|
+
archive_entry_set_devminor(_self,NUM2INT(dev));
|
411
|
+
return dev;
|
412
|
+
}
|
413
|
+
/*
|
414
|
+
* call-seq:
|
415
|
+
* entry.rdev = Integer
|
416
|
+
*
|
417
|
+
* sets rdev
|
418
|
+
*/
|
419
|
+
VALUE ArchiveEntry_set_rdev(VALUE self,VALUE dev){
|
420
|
+
archive_entry_set_dev(_self,NUM2INT(dev));
|
421
|
+
return dev;
|
422
|
+
}
|
423
|
+
/*
|
424
|
+
* call-seq:
|
425
|
+
* entry.rdevminor = Integer
|
426
|
+
*
|
427
|
+
* sets rdevminor
|
428
|
+
*/
|
429
|
+
VALUE ArchiveEntry_set_rdevmajor(VALUE self,VALUE dev){
|
430
|
+
archive_entry_set_rdevmajor(_self,NUM2INT(dev));
|
431
|
+
return dev;
|
432
|
+
}
|
433
|
+
/*
|
434
|
+
* call-seq:
|
435
|
+
* entry.rdevmajor = Integer
|
436
|
+
*
|
437
|
+
* sets rdevmajor
|
438
|
+
*/
|
439
|
+
VALUE ArchiveEntry_set_rdevminor(VALUE self,VALUE dev){
|
440
|
+
archive_entry_set_rdevminor(_self,NUM2INT(dev));
|
441
|
+
return dev;
|
442
|
+
}
|
443
|
+
/*
|
444
|
+
* call-seq:
|
445
|
+
* entry <=> other -> -1,0,1 or nil
|
446
|
+
*
|
447
|
+
* compares two entries
|
448
|
+
*/
|
449
|
+
VALUE ArchiveEntry_compare(VALUE self,VALUE other)
|
450
|
+
{
|
451
|
+
if(rb_obj_is_kind_of(other,rb_cArchiveEntry) != Qtrue)
|
452
|
+
return Qnil;
|
453
|
+
else {
|
454
|
+
return rb_funcall(ArchiveEntry_mtime(self),rb_intern("<=>"),1,ArchiveEntry_mtime(other));
|
455
|
+
}
|
456
|
+
}
|
457
|
+
|
458
|
+
/*
|
459
|
+
* call-seq:
|
460
|
+
* entry.inspect -> String
|
461
|
+
*
|
462
|
+
* returns readable string.
|
463
|
+
*/
|
464
|
+
VALUE ArchiveEntry_inspect(VALUE self){
|
465
|
+
VALUE array[3];
|
466
|
+
array[0]=rb_str_new2("#<%s:%s>");
|
467
|
+
array[1]=rb_class_of(self);
|
468
|
+
array[2]=ArchiveEntry_path(self);
|
469
|
+
return rb_f_sprintf(3,array);
|
470
|
+
}
|
471
|
+
|
472
|
+
|
473
|
+
//ACL added later with acl gem
|
474
|
+
|
475
|
+
VALUE ArchiveEntry_acl(VALUE self){
|
476
|
+
archive_entry_acl_reset(_self,ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
|
477
|
+
int type,permset,tag,qual;
|
478
|
+
const char* name;
|
479
|
+
while(archive_entry_acl_next(_self, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT,&type, &permset, &tag,&qual, &name) == 0){
|
480
|
+
rb_warn("%i %i %i %s",permset,tag,qual,name);
|
481
|
+
}
|
482
|
+
return Qnil;
|
483
|
+
}
|
484
|
+
|
485
|
+
VALUE ArchiveEntry_access_acl_count(VALUE self){
|
486
|
+
return INT2NUM(archive_entry_acl_count(_self,ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
|
487
|
+
}
|
488
|
+
|
489
|
+
VALUE ArchiveEntry_acl_add(VALUE self){
|
490
|
+
archive_entry_acl_add_entry(_self,ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, ARCHIVE_ENTRY_ACL_GROUP,
|
491
|
+
101, "abc");
|
492
|
+
return self;
|
493
|
+
}
|
494
|
+
|
495
|
+
/* TODO does not work
|
496
|
+
VALUE ArchiveEntry_initialize_copy(VALUE self,VALUE source)
|
497
|
+
{
|
498
|
+
VALUE result = rb_call_super(1,&source);
|
499
|
+
archive_entry* vself = _self;
|
500
|
+
archive_entry* vsource = archive_entry_clone(wrap<archive_entry*>(source));
|
501
|
+
*vself = *vsource;
|
502
|
+
|
503
|
+
return result;
|
504
|
+
}
|
505
|
+
*/
|
506
|
+
|
507
|
+
|
508
|
+
/* Document-attr: atime
|
509
|
+
*
|
510
|
+
* Encapsulate the writing and reading of the configuration
|
511
|
+
* file. ...
|
512
|
+
*/
|
513
|
+
/* Document-attr: ctime
|
514
|
+
*
|
515
|
+
* Encapsulate the writing and reading of the configuration
|
516
|
+
* file. ...
|
517
|
+
*/
|
518
|
+
/* Document-attr: mtime
|
519
|
+
*
|
520
|
+
* Encapsulate the writing and reading of the configuration
|
521
|
+
* file. ...
|
522
|
+
*/
|
523
|
+
|
524
|
+
void Init_archive_entry(VALUE rb_cArchive){
|
525
|
+
#if(0)
|
526
|
+
rb_cArchive = rb_define_class("Archive",rb_cObject);
|
527
|
+
rb_define_attr(rb_cArchiveEntry,"atime",1,1);
|
528
|
+
rb_define_attr(rb_cArchiveEntry,"ctime",1,1);
|
529
|
+
rb_define_attr(rb_cArchiveEntry,"mtime",1,1);
|
530
|
+
rb_define_attr(rb_cArchiveEntry,"birthtime",1,1);
|
531
|
+
#endif
|
532
|
+
rb_cArchiveEntry = rb_define_class_under(rb_cArchive,"Entry",rb_cObject);
|
533
|
+
rb_define_alloc_func(rb_cArchiveEntry,ArchiveEntry_alloc);
|
534
|
+
//rb_define_private_method(rb_cArchiveEntry,"initialize_copy",RUBY_METHOD_FUNC(ArchiveEntry_initialize_copy),1);
|
535
|
+
rb_define_method(rb_cArchiveEntry,"inspect",RUBY_METHOD_FUNC(ArchiveEntry_inspect),0);
|
536
|
+
|
537
|
+
rb_define_method(rb_cArchiveEntry,"gname",RUBY_METHOD_FUNC(ArchiveEntry_gname),0);
|
538
|
+
rb_define_method(rb_cArchiveEntry,"uname",RUBY_METHOD_FUNC(ArchiveEntry_uname),0);
|
539
|
+
rb_define_method(rb_cArchiveEntry,"gid",RUBY_METHOD_FUNC(ArchiveEntry_gid),0);
|
540
|
+
rb_define_method(rb_cArchiveEntry,"uid",RUBY_METHOD_FUNC(ArchiveEntry_uid),0);
|
541
|
+
|
542
|
+
rb_define_method(rb_cArchiveEntry,"gname=",RUBY_METHOD_FUNC(ArchiveEntry_set_gname),1);
|
543
|
+
rb_define_method(rb_cArchiveEntry,"uname=",RUBY_METHOD_FUNC(ArchiveEntry_set_uname),1);
|
544
|
+
rb_define_method(rb_cArchiveEntry,"gid=",RUBY_METHOD_FUNC(ArchiveEntry_set_gid),1);
|
545
|
+
rb_define_method(rb_cArchiveEntry,"uid=",RUBY_METHOD_FUNC(ArchiveEntry_set_uid),1);
|
546
|
+
|
547
|
+
rb_define_method(rb_cArchiveEntry,"path",RUBY_METHOD_FUNC(ArchiveEntry_path),0);
|
548
|
+
rb_define_method(rb_cArchiveEntry,"symlink",RUBY_METHOD_FUNC(ArchiveEntry_symlink),0);
|
549
|
+
rb_define_method(rb_cArchiveEntry,"hardlink",RUBY_METHOD_FUNC(ArchiveEntry_hardlink),0);
|
550
|
+
rb_define_method(rb_cArchiveEntry,"sourcepath",RUBY_METHOD_FUNC(ArchiveEntry_sourcepath),0);
|
551
|
+
|
552
|
+
rb_define_method(rb_cArchiveEntry,"path=",RUBY_METHOD_FUNC(ArchiveEntry_set_path),1);
|
553
|
+
rb_define_method(rb_cArchiveEntry,"symlink=",RUBY_METHOD_FUNC(ArchiveEntry_set_symlink),1);
|
554
|
+
rb_define_method(rb_cArchiveEntry,"hardlink=",RUBY_METHOD_FUNC(ArchiveEntry_set_hardlink),1);
|
555
|
+
|
556
|
+
rb_define_method(rb_cArchiveEntry,"atime",RUBY_METHOD_FUNC(ArchiveEntry_atime),0);//:nodoc:
|
557
|
+
rb_define_method(rb_cArchiveEntry,"ctime",RUBY_METHOD_FUNC(ArchiveEntry_ctime),0);
|
558
|
+
rb_define_method(rb_cArchiveEntry,"mtime",RUBY_METHOD_FUNC(ArchiveEntry_mtime),0);
|
559
|
+
rb_define_method(rb_cArchiveEntry,"birthtime",RUBY_METHOD_FUNC(ArchiveEntry_birthtime),0);
|
560
|
+
|
561
|
+
rb_define_method(rb_cArchiveEntry,"atime=",RUBY_METHOD_FUNC(ArchiveEntry_set_atime),1);//:nodoc:
|
562
|
+
rb_define_method(rb_cArchiveEntry,"ctime=",RUBY_METHOD_FUNC(ArchiveEntry_set_ctime),1);
|
563
|
+
rb_define_method(rb_cArchiveEntry,"mtime=",RUBY_METHOD_FUNC(ArchiveEntry_set_mtime),1);
|
564
|
+
rb_define_method(rb_cArchiveEntry,"birthtime=",RUBY_METHOD_FUNC(ArchiveEntry_set_birthtime),1);
|
565
|
+
|
566
|
+
rb_define_method(rb_cArchiveEntry,"dev",RUBY_METHOD_FUNC(ArchiveEntry_dev),0);
|
567
|
+
rb_define_method(rb_cArchiveEntry,"dev_major",RUBY_METHOD_FUNC(ArchiveEntry_devmajor),0);
|
568
|
+
rb_define_method(rb_cArchiveEntry,"dev_minor",RUBY_METHOD_FUNC(ArchiveEntry_devminor),0);
|
569
|
+
rb_define_method(rb_cArchiveEntry,"rdev",RUBY_METHOD_FUNC(ArchiveEntry_rdev),0);
|
570
|
+
rb_define_method(rb_cArchiveEntry,"rdev_major",RUBY_METHOD_FUNC(ArchiveEntry_rdevmajor),0);
|
571
|
+
rb_define_method(rb_cArchiveEntry,"rdev_minor",RUBY_METHOD_FUNC(ArchiveEntry_rdevminor),0);
|
572
|
+
|
573
|
+
rb_define_method(rb_cArchiveEntry,"dev=",RUBY_METHOD_FUNC(ArchiveEntry_set_dev),1);
|
574
|
+
rb_define_method(rb_cArchiveEntry,"dev_major=",RUBY_METHOD_FUNC(ArchiveEntry_set_devmajor),1);
|
575
|
+
rb_define_method(rb_cArchiveEntry,"dev_minor=",RUBY_METHOD_FUNC(ArchiveEntry_set_devminor),1);
|
576
|
+
rb_define_method(rb_cArchiveEntry,"rdev=",RUBY_METHOD_FUNC(ArchiveEntry_set_rdev),1);
|
577
|
+
rb_define_method(rb_cArchiveEntry,"rdev_major=",RUBY_METHOD_FUNC(ArchiveEntry_set_rdevmajor),1);
|
578
|
+
rb_define_method(rb_cArchiveEntry,"rdev_minor=",RUBY_METHOD_FUNC(ArchiveEntry_set_rdevminor),1);
|
579
|
+
|
580
|
+
rb_include_module(rb_cArchiveEntry,rb_mComparable);
|
581
|
+
rb_define_method(rb_cArchiveEntry,"<=>",RUBY_METHOD_FUNC(ArchiveEntry_compare),1);
|
582
|
+
|
583
|
+
rb_define_alias(rb_cArchiveEntry,"to_s","path");
|
584
|
+
/*
|
585
|
+
//rb_define_method(rb_cArchiveEntry,"acl",RUBY_METHOD_FUNC(ArchiveEntry_acl),0);
|
586
|
+
//rb_define_method(rb_cArchiveEntry,"acl_add",RUBY_METHOD_FUNC(ArchiveEntry_acl_add),0);
|
587
|
+
|
588
|
+
//rb_define_method(rb_cArchiveEntry,"access_acl_count",RUBY_METHOD_FUNC(ArchiveEntry_access_acl_count),0);
|
589
|
+
//*/
|
590
|
+
|
591
|
+
|
592
|
+
}
|
data/ext/extconf.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#Encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
This file is part of libarchive-ruby.
|
4
|
+
|
5
|
+
libarchive-ruby is a Ruby binding for the C library libarchive.
|
6
|
+
|
7
|
+
Copyright © 2011 Hans Mackowiak
|
8
|
+
|
9
|
+
libarchive-ruby is free software; you can redistribute it and/or modify
|
10
|
+
it under the terms of the GNU General Public License as published by
|
11
|
+
the Free Software Foundation; either version 2 of the License, or
|
12
|
+
(at your option) any later version.
|
13
|
+
|
14
|
+
libarchive-ruby is distributed in the hope that it will be useful,
|
15
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
GNU General Public License for more details.
|
18
|
+
|
19
|
+
You should have received a copy of the GNU General Public License along
|
20
|
+
with libarchive-ruby; if not, write to the Free Software Foundation, Inc.,
|
21
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
22
|
+
=end
|
23
|
+
|
24
|
+
require 'mkmf'
|
25
|
+
|
26
|
+
dir_config("archive")
|
27
|
+
pkg_config("libarchive")
|
28
|
+
find_library("archive","main")
|
29
|
+
find_header("archive.h")
|
30
|
+
|
31
|
+
|
32
|
+
$CFLAGS += " -Wall"
|
33
|
+
|
34
|
+
unless have_func("rb_string_value_cstr","ruby.h")
|
35
|
+
abort("missing VALUE to char convert!")
|
36
|
+
end
|
37
|
+
|
38
|
+
create_makefile("archive")
|
data/ext/main.hpp
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
/****************************************************************************
|
2
|
+
This file is part of libarchive-ruby.
|
3
|
+
|
4
|
+
libarchive-ruby is a Ruby binding for the C library libarchive.
|
5
|
+
|
6
|
+
Copyright (C) 2011 Hans Mackowiak
|
7
|
+
|
8
|
+
libarchive-ruby is free software; you can redistribute it and/or modify
|
9
|
+
it under the terms of the GNU General Public License as published by
|
10
|
+
the Free Software Foundation; either version 2 of the License, or
|
11
|
+
(at your option) any later version.
|
12
|
+
|
13
|
+
libarchive-ruby is distributed in the hope that it will be useful,
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
GNU General Public License for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU General Public License along
|
19
|
+
with libarchive-ruby; if not, write to the Free Software Foundation, Inc.,
|
20
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
21
|
+
****************************************************************************/
|
22
|
+
|
23
|
+
#ifndef __RubyAchiveMain_H__
|
24
|
+
#define __RubyAchiveMain_H__
|
25
|
+
#include <ruby.h>
|
26
|
+
#include <archive.h>
|
27
|
+
#include <archive_entry.h>
|
28
|
+
#include <fcntl.h>
|
29
|
+
#include <string>
|
30
|
+
extern VALUE rb_cArchive,rb_cArchiveEntry;
|
31
|
+
void Init_archive_entry(VALUE m);
|
32
|
+
|
33
|
+
template <typename T>
|
34
|
+
VALUE wrap(T *arg){ return Qnil;};
|
35
|
+
template <typename T>
|
36
|
+
VALUE wrap(T arg){ return Qnil;};
|
37
|
+
template <typename T>
|
38
|
+
T wrap(const VALUE &arg){};
|
39
|
+
|
40
|
+
enum archive_type {archive_path,archive_fd,archive_buffer,archive_ruby};
|
41
|
+
|
42
|
+
struct rarchive{
|
43
|
+
//union drumrum?
|
44
|
+
std::string path;
|
45
|
+
VALUE ruby;
|
46
|
+
std::string buffer;
|
47
|
+
int fd;
|
48
|
+
archive_type type;
|
49
|
+
int format;
|
50
|
+
int compression;
|
51
|
+
};
|
52
|
+
|
53
|
+
template <>
|
54
|
+
inline VALUE wrap< rarchive >(rarchive *file )
|
55
|
+
{
|
56
|
+
return Data_Wrap_Struct(rb_cArchive, NULL, free, file);
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
template <>
|
61
|
+
inline rarchive* wrap< rarchive* >(const VALUE &vfile)
|
62
|
+
{
|
63
|
+
if ( ! rb_obj_is_kind_of(vfile, rb_cArchive) )
|
64
|
+
return NULL;
|
65
|
+
rarchive *file;
|
66
|
+
Data_Get_Struct( vfile, rarchive, file);
|
67
|
+
return file;
|
68
|
+
}
|
69
|
+
template <>
|
70
|
+
inline VALUE wrap< archive_entry >(struct archive_entry *entry )
|
71
|
+
{
|
72
|
+
return Data_Wrap_Struct(rb_cArchiveEntry, NULL, NULL, archive_entry_clone(entry));
|
73
|
+
}
|
74
|
+
|
75
|
+
template <>
|
76
|
+
inline archive_entry* wrap< archive_entry* >(const VALUE &vfile)
|
77
|
+
{
|
78
|
+
if ( ! rb_obj_is_kind_of(vfile, rb_cArchiveEntry) )
|
79
|
+
return NULL;
|
80
|
+
archive_entry *file;
|
81
|
+
Data_Get_Struct( vfile, archive_entry, file);
|
82
|
+
return file;
|
83
|
+
}
|
84
|
+
|
85
|
+
#endif /* __RubyAchiveMain_H__ */
|
86
|
+
|