tarruby 0.1.1-mswin32 → 0.1.2-mswin32

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/README.txt CHANGED
@@ -21,7 +21,7 @@ gem install tarruby
21
21
 
22
22
  require 'tarruby'
23
23
 
24
- Tar.open('foo.tar', File::RDONLY, Tar::GNU) do |tar|
24
+ Tar.open('foo.tar', File::RDONLY, 0644, Tar::GNU | Tar::VERBOSE) do |tar|
25
25
  while tar.read # or 'tar.each do ...'
26
26
  puts tar.pathname
27
27
  tar.print_long_ls
@@ -48,7 +48,7 @@ gem install tarruby
48
48
 
49
49
  require 'tarruby'
50
50
 
51
- Tar.open('bar.tar', File::CREAT | File::WRONLY, Tar::GNU) do |tar|
51
+ Tar.open('bar.tar', File::CREAT | File::WRONLY, 0644, Tar::GNU | Tar::VERBOSE) do |tar|
52
52
  Dir.glob('**/*.c').each do |filename|
53
53
  tar.append_file(filename)
54
54
  end
data/ext/tarruby.c CHANGED
@@ -32,7 +32,7 @@
32
32
 
33
33
  #define INT2TIME(i) rb_funcall(rb_cTime, rb_intern("at"), 1, INT2NUM(i))
34
34
 
35
- #define VERSION "0.1.1"
35
+ #define VERSION "0.1.2"
36
36
 
37
37
  static VALUE Tar;
38
38
  static VALUE Error;
@@ -153,6 +153,14 @@ static tartype_t bztype = {
153
153
  };
154
154
  #endif
155
155
 
156
+ static void strip_sep(char *path) {
157
+ int len = strlen(path);
158
+
159
+ if (path[len - 1] == '/' || path[len - 1] == '\\') {
160
+ path[len - 1] = '\0';
161
+ }
162
+ }
163
+
156
164
  static VALUE tarruby_tar_alloc(VALUE klass) {
157
165
  struct tarruby_tar *p = ALLOC(struct tarruby_tar);
158
166
 
@@ -163,18 +171,23 @@ static VALUE tarruby_tar_alloc(VALUE klass) {
163
171
  }
164
172
 
165
173
  /* */
166
- static VALUE tarruby_close(VALUE self) {
174
+ static VALUE tarruby_close0(VALUE self, int abort) {
167
175
  struct tarruby_tar *p_tar;
168
176
 
169
177
  Data_Get_Struct(self, struct tarruby_tar, p_tar);
170
178
 
171
- if(tar_close(p_tar->tar) != 0) {
179
+ if(tar_close(p_tar->tar) != 0 && abort) {
172
180
  rb_raise(Error, "Close archive failed: %s", strerror(errno));
173
181
  }
174
182
 
175
183
  return Qnil;
176
184
  }
177
185
 
186
+ /* */
187
+ static VALUE tarruby_close(VALUE self) {
188
+ return tarruby_close0(self, 1);
189
+ }
190
+
178
191
  static VALUE tarruby_s_open0(int argc, VALUE *argv, VALUE self, tartype_t *tartype) {
179
192
  VALUE tar, pathname, oflags, mode, options;
180
193
  struct tarruby_tar *p_tar;
@@ -200,7 +213,7 @@ static VALUE tarruby_s_open0(int argc, VALUE *argv, VALUE self, tartype_t *tarty
200
213
  int status;
201
214
 
202
215
  retval = rb_protect(rb_yield, tar, &status);
203
- tarruby_close(tar);
216
+ tarruby_close0(tar, 0);
204
217
 
205
218
  if (status != 0) {
206
219
  rb_jump_tag(status);
@@ -240,10 +253,12 @@ static VALUE tarruby_append_file(int argc, VALUE *argv, VALUE self) {
240
253
  rb_scan_args(argc, argv, "11", &realname, &savename);
241
254
  Check_Type(realname, T_STRING);
242
255
  s_realname = RSTRING_PTR(realname);
256
+ strip_sep(s_realname);
243
257
 
244
258
  if (!NIL_P(savename)) {
245
259
  Check_Type(savename, T_STRING);
246
260
  s_savename = RSTRING_PTR(savename);
261
+ strip_sep(s_savename);
247
262
  }
248
263
 
249
264
  Data_Get_Struct(self, struct tarruby_tar, p_tar);
@@ -264,10 +279,12 @@ static VALUE tarruby_append_tree(int argc, VALUE *argv, VALUE self) {
264
279
  rb_scan_args(argc, argv, "11", &realdir, &savedir);
265
280
  Check_Type(realdir, T_STRING);
266
281
  s_realdir = RSTRING_PTR(realdir);
282
+ strip_sep(s_realdir);
267
283
 
268
284
  if (!NIL_P(savedir)) {
269
285
  Check_Type(savedir, T_STRING);
270
286
  s_savedir = RSTRING_PTR(savedir);
287
+ strip_sep(s_savedir);
271
288
  }
272
289
 
273
290
  Data_Get_Struct(self, struct tarruby_tar, p_tar);
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tarruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: mswin32
6
6
  authors:
7
7
  - winebarrel
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-11 00:00:00 +09:00
12
+ date: 2008-09-13 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15