zipruby 0.2.6 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of zipruby might be problematic. Click here for more details.

data/ext/foo.txt DELETED
@@ -1,315 +0,0 @@
1
- --- zipruby_archive.c.r112 2008-07-13 16:12:21.234375000 +0900
2
- +++ zipruby_archive.c 2008-07-13 16:09:45.640625000 +0900
3
- @@ -21,15 +21,15 @@ static VALUE zipruby_archive_add_buffer(
4
- static VALUE zipruby_archive_add_file(int argc, VALUE *argv, VALUE self);
5
- static VALUE zipruby_archive_add_filep(int argc, VALUE *argv, VALUE self);
6
- static VALUE zipruby_archive_add_function(int argc, VALUE *argv, VALUE self);
7
- -static VALUE zipruby_archive_replace_buffer(VALUE self, VALUE index, VALUE source);
8
- -static VALUE zipruby_archive_replace_file(VALUE self, VALUE index, VALUE fname);
9
- +static VALUE zipruby_archive_replace_buffer(int argc, VALUE *argv, VALUE self);
10
- +static VALUE zipruby_archive_replace_file(int argc, VALUE* argv, VALUE self);
11
- static VALUE zipruby_archive_replace_filep(VALUE self, VALUE index, VALUE file);
12
- static VALUE zipruby_archive_replace_function(int argc, VALUE *argv, VALUE self);
13
- -static VALUE zipruby_archive_add_or_replace_buffer(VALUE self, VALUE name, VALUE source);
14
- +static VALUE zipruby_archive_add_or_replace_buffer(int argc, VALUE *argv, VALUE self);
15
- static VALUE zipruby_archive_add_or_replace_file(int argc, VALUE *argv, VALUE self);
16
- static VALUE zipruby_archive_add_or_replace_filep(int argc, VALUE *argv, VALUE self);
17
- static VALUE zipruby_archive_add_or_replace_function(int argc, VALUE *argv, VALUE self);
18
- -static VALUE zipruby_archive_update(VALUE self, VALUE srcarchive);
19
- +static VALUE zipruby_archive_update(int argc, VALUE *argv, VALUE self);
20
- static VALUE zipruby_archive_get_comment(int argc, VALUE *argv, VALUE self);
21
- static VALUE zipruby_archive_set_comment(VALUE self, VALUE comment);
22
- static VALUE zipruby_archive_locate_name(int argc, VALUE *argv, VALUE self);
23
- @@ -65,15 +65,15 @@ void Init_zipruby_archive() {
24
- rb_define_method(Archive, "add_file", zipruby_archive_add_file, -1);
25
- rb_define_method(Archive, "add_filep", zipruby_archive_add_filep, -1);
26
- rb_define_method(Archive, "add", zipruby_archive_add_function, -1);
27
- - rb_define_method(Archive, "replace_buffer", zipruby_archive_replace_buffer, 2);
28
- - rb_define_method(Archive, "replace_file", zipruby_archive_replace_file, 2);
29
- + rb_define_method(Archive, "replace_buffer", zipruby_archive_replace_buffer, -1);
30
- + rb_define_method(Archive, "replace_file", zipruby_archive_replace_file, -1);
31
- rb_define_method(Archive, "replace_filep", zipruby_archive_replace_filep, 2);
32
- rb_define_method(Archive, "replace", zipruby_archive_replace_function, -1);
33
- - rb_define_method(Archive, "add_or_replace_buffer", zipruby_archive_add_or_replace_buffer, 2);
34
- + rb_define_method(Archive, "add_or_replace_buffer", zipruby_archive_add_or_replace_buffer, -1);
35
- rb_define_method(Archive, "add_or_replace_file", zipruby_archive_add_or_replace_file, -1);
36
- rb_define_method(Archive, "add_or_replace_filep", zipruby_archive_add_or_replace_filep, -1);
37
- rb_define_method(Archive, "add_or_replace", zipruby_archive_add_or_replace_function, -1);
38
- - rb_define_method(Archive, "update", zipruby_archive_update, 1);
39
- + rb_define_method(Archive, "update", zipruby_archive_update, -1);
40
- rb_define_method(Archive, "<<", zipruby_archive_add_filep, -1);
41
- rb_define_method(Archive, "get_comment", zipruby_archive_get_comment, -1);
42
- rb_define_method(Archive, "comment", zipruby_archive_get_comment, -1);
43
- @@ -320,24 +320,31 @@ static VALUE zipruby_archive_add_buffer(
44
- }
45
-
46
- /* */
47
- -static VALUE zipruby_archive_replace_buffer(VALUE self, VALUE index, VALUE source) {
48
- +static VALUE zipruby_archive_replace_buffer(int argc, VALUE *argv, VALUE self) {
49
- struct zipruby_archive *p_archive;
50
- struct zip_source *zsource;
51
- - int i_index;
52
- + VALUE index, source, flags;
53
- + int i_index, i_flags = 0;
54
- char *data;
55
- off_t len;
56
-
57
- + rb_scan_args(argc, argv, "21", &index, &source, &flags);
58
- +
59
- if (!rb_obj_is_instance_of(index, rb_cString) && !rb_obj_is_instance_of(index, rb_cFixnum)) {
60
- rb_raise(rb_eTypeError, "wrong argument type %s (expected Fixnum or String)", rb_class2name(CLASS_OF(index)));
61
- }
62
-
63
- + if (!NIL_P(flags)) {
64
- + i_flags = NUM2INT(flags);
65
- + }
66
- +
67
- Check_Type(source, T_STRING);
68
- Data_Get_Struct(self, struct zipruby_archive, p_archive);
69
- Check_Archive(p_archive);
70
-
71
- if (rb_obj_is_instance_of(index, rb_cFixnum)) {
72
- i_index = NUM2INT(index);
73
- - } else if ((i_index = zip_name_locate(p_archive->archive, StringValuePtr(index), ZIP_FL_NOCASE)) == -1) {
74
- + } else if ((i_index = zip_name_locate(p_archive->archive, StringValuePtr(index), i_flags)) == -1) {
75
- rb_raise(Error, "Replace file failed - %s: Archive does not contain a file", StringValuePtr(index));
76
- }
77
-
78
- @@ -365,18 +372,26 @@ static VALUE zipruby_archive_replace_buf
79
- }
80
-
81
- /* */
82
- -static VALUE zipruby_archive_add_or_replace_buffer(VALUE self, VALUE name, VALUE source) {
83
- +static VALUE zipruby_archive_add_or_replace_buffer(int argc, VALUE *argv, VALUE self) {
84
- struct zipruby_archive *p_archive;
85
- - int index;
86
- + VALUE name, source, flags;
87
- + int index, i_flags = 0;
88
- +
89
- + rb_scan_args(argc, argv, "21", &name, &source, &flags);
90
- +
91
- + if (!NIL_P(flags)) {
92
- + i_flags = NUM2INT(flags);
93
- + }
94
-
95
- Check_Type(name, T_STRING);
96
- Data_Get_Struct(self, struct zipruby_archive, p_archive);
97
- Check_Archive(p_archive);
98
-
99
- - index = zip_name_locate(p_archive->archive, StringValuePtr(name), ZIP_FL_NOCASE);
100
- + index = zip_name_locate(p_archive->archive, StringValuePtr(name), i_flags);
101
-
102
- if (index >= 0) {
103
- - return zipruby_archive_replace_buffer(self, INT2NUM(index), source);
104
- + VALUE _args[] = { INT2NUM(index), source };
105
- + return zipruby_archive_replace_buffer(2, _args, self);
106
- } else {
107
- return zipruby_archive_add_buffer(self, name, source);
108
- }
109
- @@ -420,22 +435,29 @@ static VALUE zipruby_archive_add_file(in
110
- }
111
-
112
- /* */
113
- -static VALUE zipruby_archive_replace_file(VALUE self, VALUE index, VALUE fname) {
114
- +static VALUE zipruby_archive_replace_file(int argc, VALUE* argv, VALUE self) {
115
- struct zipruby_archive *p_archive;
116
- struct zip_source *zsource;
117
- - int i_index;
118
- + VALUE index, fname, flags;
119
- + int i_index, i_flags = 0;
120
- +
121
- + rb_scan_args(argc, argv, "21", &index, &fname, &flags);
122
-
123
- if (!rb_obj_is_instance_of(index, rb_cString) && !rb_obj_is_instance_of(index, rb_cFixnum)) {
124
- rb_raise(rb_eTypeError, "wrong argument type %s (expected Fixnum or String)", rb_class2name(CLASS_OF(index)));
125
- }
126
-
127
- + if (!NIL_P(flags)) {
128
- + i_flags = NUM2INT(flags);
129
- + }
130
- +
131
- Check_Type(fname, T_STRING);
132
- Data_Get_Struct(self, struct zipruby_archive, p_archive);
133
- Check_Archive(p_archive);
134
-
135
- if (rb_obj_is_instance_of(index, rb_cFixnum)) {
136
- i_index = NUM2INT(index);
137
- - } else if ((i_index = zip_name_locate(p_archive->archive, StringValuePtr(index), ZIP_FL_NOCASE)) == -1) {
138
- + } else if ((i_index = zip_name_locate(p_archive->archive, StringValuePtr(index), i_flags)) == -1) {
139
- rb_raise(Error, "Replace file failed - %s: Archive does not contain a file", StringValuePtr(index));
140
- }
141
-
142
- @@ -455,11 +477,16 @@ static VALUE zipruby_archive_replace_fil
143
-
144
- /* */
145
- static VALUE zipruby_archive_add_or_replace_file(int argc, VALUE *argv, VALUE self) {
146
- - VALUE name, fname;
147
- + VALUE name, fname, flags;
148
- struct zipruby_archive *p_archive;
149
- - int index;
150
- + int index, i_flags = 0;
151
-
152
- - rb_scan_args(argc, argv, "11", &name, &fname);
153
- + rb_scan_args(argc, argv, "12", &name, &fname, &flags);
154
- +
155
- + if (NIL_P(flags) && FIXNUM_P(fname)) {
156
- + flags = fname;
157
- + fname = Qnil;
158
- + }
159
-
160
- if (NIL_P(fname)) {
161
- fname = name;
162
- @@ -472,16 +499,22 @@ static VALUE zipruby_archive_add_or_repl
163
- name = rb_funcall(rb_cFile, rb_intern("basename"), 1, fname);
164
- }
165
-
166
- + if (!NIL_P(flags)) {
167
- + i_flags = NUM2INT(flags);
168
- + }
169
- +
170
- Check_Type(name, T_STRING);
171
- Data_Get_Struct(self, struct zipruby_archive, p_archive);
172
- Check_Archive(p_archive);
173
-
174
- - index = zip_name_locate(p_archive->archive, StringValuePtr(name), ZIP_FL_NOCASE);
175
- + index = zip_name_locate(p_archive->archive, StringValuePtr(name), i_flags);
176
-
177
- if (index >= 0) {
178
- - return zipruby_archive_replace_file(self, INT2NUM(index), fname);
179
- + VALUE _args[] = { INT2NUM(index), fname };
180
- + return zipruby_archive_replace_file(2, _args, self);
181
- } else {
182
- - return zipruby_archive_add_file(argc, argv, self);
183
- + VALUE _args[] = { name, fname };
184
- + return zipruby_archive_add_file(2, _args, self);
185
- }
186
- }
187
-
188
- @@ -510,20 +543,28 @@ static VALUE zipruby_archive_add_filep(i
189
- /* */
190
- static VALUE zipruby_archive_replace_filep(VALUE self, VALUE index, VALUE file) {
191
- VALUE source;
192
- + VALUE _args[2];
193
-
194
- Check_Type(file, T_FILE);
195
- source = rb_funcall(file, rb_intern("read"), 0);
196
-
197
- - return zipruby_archive_replace_buffer(self, index, source);
198
- + _args[0] = index;
199
- + _args[1] = source;
200
- + return zipruby_archive_replace_buffer(2, _args, self);
201
- }
202
-
203
- /* */
204
- static VALUE zipruby_archive_add_or_replace_filep(int argc, VALUE *argv, VALUE self) {
205
- - VALUE name, file;
206
- + VALUE name, file, flags;
207
- struct zipruby_archive *p_archive;
208
- - int index;
209
- + int index, i_flags = 0;
210
-
211
- - rb_scan_args(argc, argv, "11", &name, &file);
212
- + rb_scan_args(argc, argv, "12", &name, &file, &flags);
213
- +
214
- + if (NIL_P(flags) && FIXNUM_P(file)) {
215
- + flags = file;
216
- + file = Qnil;
217
- + }
218
-
219
- if (NIL_P(file)) {
220
- file = name;
221
- @@ -536,16 +577,21 @@ static VALUE zipruby_archive_add_or_repl
222
- name = rb_funcall(rb_cFile, rb_intern("basename"), 1, rb_funcall(file, rb_intern("path"), 0));
223
- }
224
-
225
- + if (!NIL_P(flags)) {
226
- + i_flags = NUM2INT(flags);
227
- + }
228
- +
229
- Check_Type(name, T_STRING);
230
- Data_Get_Struct(self, struct zipruby_archive, p_archive);
231
- Check_Archive(p_archive);
232
-
233
- - index = zip_name_locate(p_archive->archive, StringValuePtr(name), ZIP_FL_NOCASE);
234
- + index = zip_name_locate(p_archive->archive, StringValuePtr(name), i_flags);
235
-
236
- if (index >= 0) {
237
- return zipruby_archive_replace_filep(self, INT2NUM(index), file);
238
- } else {
239
- - return zipruby_archive_add_filep(argc, argv, self);
240
- + VALUE _args[] = { name, file };
241
- + return zipruby_archive_add_filep(2, _args, self);
242
- }
243
- }
244
-
245
- @@ -638,34 +684,52 @@ static VALUE zipruby_archive_replace_fun
246
-
247
- /* */
248
- static VALUE zipruby_archive_add_or_replace_function(int argc, VALUE *argv, VALUE self) {
249
- - VALUE name, mtime;
250
- + VALUE name, mtime, flags;
251
- struct zipruby_archive *p_archive;
252
- - int index;
253
- + int index, i_flags = 0;
254
- +
255
- + rb_scan_args(argc, argv, "12", &name, &mtime, &flags);
256
- +
257
- + if (NIL_P(flags) && FIXNUM_P(mtime)) {
258
- + flags = mtime;
259
- + mtime = Qnil;
260
- + }
261
- +
262
- + if (!NIL_P(flags)) {
263
- + i_flags = NUM2INT(flags);
264
- + }
265
-
266
- - rb_scan_args(argc, argv, "11", &name, &mtime);
267
- Check_Type(name, T_STRING);
268
- Data_Get_Struct(self, struct zipruby_archive, p_archive);
269
- Check_Archive(p_archive);
270
-
271
- - index = zip_name_locate(p_archive->archive, StringValuePtr(name), ZIP_FL_NOCASE);
272
- + index = zip_name_locate(p_archive->archive, StringValuePtr(name), i_flags);
273
-
274
- if (index >= 0) {
275
- - VALUE args[] = { INT2NUM(index), mtime };
276
- - return zipruby_archive_replace_function(2, args, self);
277
- + VALUE _args[] = { INT2NUM(index), mtime };
278
- + return zipruby_archive_replace_function(2, _args, self);
279
- } else {
280
- - return zipruby_archive_add_function(argc, argv, self);
281
- + VALUE _args[] = { name, mtime };
282
- + return zipruby_archive_add_function(2, _args, self);
283
- }
284
- }
285
-
286
- /* */
287
- -static VALUE zipruby_archive_update(VALUE self, VALUE srcarchive) {
288
- +static VALUE zipruby_archive_update(int argc, VALUE *argv, VALUE self) {
289
- struct zipruby_archive *p_archive, *p_srcarchive;
290
- - int i, num_files;
291
- + VALUE srcarchive, flags;
292
- + int i, num_files, i_flags = 0;
293
- +
294
- + rb_scan_args(argc, argv, "11", &srcarchive, &flags);
295
-
296
- if (!rb_obj_is_instance_of(srcarchive, Archive)) {
297
- rb_raise(rb_eTypeError, "wrong argument type %s (expected Zip::Archive)", rb_class2name(CLASS_OF(srcarchive)));
298
- }
299
-
300
- + if (!NIL_P(flags)) {
301
- + i_flags = NUM2INT(flags);
302
- + }
303
- +
304
- Data_Get_Struct(self, struct zipruby_archive, p_archive);
305
- Check_Archive(p_archive);
306
- Data_Get_Struct(srcarchive, struct zipruby_archive, p_srcarchive);
307
- @@ -735,7 +799,7 @@ static VALUE zipruby_archive_update(VALU
308
- rb_raise(Error, "Update archive failed: %s", zip_strerror(p_srcarchive->archive));
309
- }
310
-
311
- - index = zip_name_locate(p_archive->archive, name, ZIP_FL_NOCASE);
312
- + index = zip_name_locate(p_archive->archive, name, i_flags);
313
-
314
- if (index >= 0) {
315
- if (zip_replace(p_archive->archive, i, zsource) == -1) {