tarruby 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,50 @@
1
+ CMake was initially developed by Kitware with the following sponsorship:
2
+
3
+ * National Library of Medicine at the National Institutes of Health
4
+ as part of the Insight Segmentation and Registration Toolkit (ITK).
5
+
6
+ * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
7
+ Visualization Initiative.
8
+
9
+ * National Alliance for Medical Image Computing (NAMIC) is funded by the
10
+ National Institutes of Health through the NIH Roadmap for Medical Research,
11
+ Grant U54 EB005149.
12
+
13
+ * Kitware, Inc.
14
+
15
+ The CMake copyright is as follows:
16
+
17
+ Copyright (c) 2002 Kitware, Inc., Insight Consortium
18
+ All rights reserved.
19
+
20
+ Redistribution and use in source and binary forms, with or without
21
+ modification, are permitted provided that the following conditions are
22
+ met:
23
+
24
+ * Redistributions of source code must retain the above copyright notice,
25
+ this list of conditions and the following disclaimer.
26
+
27
+ * Redistributions in binary form must reproduce the above copyright notice,
28
+ this list of conditions and the following disclaimer in the documentation
29
+ and/or other materials provided with the distribution.
30
+
31
+ * The names of Kitware, Inc., the Insight Consortium, or the names of
32
+ any consortium members, or of any contributors, may not be used to
33
+ endorse or promote products derived from this software without
34
+ specific prior written permission.
35
+
36
+ * Modified source versions must be plainly marked as such, and must
37
+ not be misrepresented as being the original software.
38
+
39
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
40
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
42
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
43
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
44
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
45
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
46
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
48
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49
+
50
+ See also the CMake web site: http://www.cmake.org for more information.
@@ -50,7 +50,7 @@ openbsd_basename(path)
50
50
 
51
51
  /* Strip trailing slashes */
52
52
  endp = path + strlen(path) - 1;
53
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
53
+ #ifndef _WIN32
54
54
  while (endp > path && *endp == '/')
55
55
  endp--;
56
56
  #else
@@ -60,7 +60,7 @@ openbsd_basename(path)
60
60
  #endif
61
61
 
62
62
  /* All slashes becomes "/" */
63
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
63
+ #ifndef _WIN32
64
64
  if (endp == path && *endp == '/') {
65
65
  (void)strcpy(bname, "/");
66
66
  return(bname);
@@ -73,7 +73,7 @@ openbsd_basename(path)
73
73
  #endif
74
74
  /* Find the start of the base */
75
75
  startp = endp;
76
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
76
+ #ifndef _WIN32
77
77
  while (startp > path && *(startp - 1) != '/')
78
78
  startp--;
79
79
  #else
@@ -50,7 +50,7 @@ openbsd_dirname(path)
50
50
 
51
51
  /* Strip trailing slashes */
52
52
  endp = path + strlen(path) - 1;
53
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
53
+ #ifndef _WIN32
54
54
  while (endp > path && *endp == '/')
55
55
  endp--;
56
56
  #else
@@ -60,7 +60,7 @@ openbsd_dirname(path)
60
60
  #endif
61
61
 
62
62
  /* Find the start of the dir */
63
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
63
+ #ifndef _WIN32
64
64
  while (endp > path && *endp != '/')
65
65
  endp--;
66
66
  #else
@@ -71,14 +71,14 @@ openbsd_dirname(path)
71
71
 
72
72
  /* Either the dir is "/" or there are no slashes */
73
73
  if (endp == path) {
74
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
74
+ #ifndef _WIN32
75
75
  (void)strcpy(bname, *endp == '/' ? "/" : ".");
76
76
  #else
77
77
  (void)strcpy(bname, (*endp == '/' || *endp == '\\') ? "/" : ".");
78
78
  #endif
79
79
  return(bname);
80
80
  } else {
81
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
81
+ #ifndef _WIN32
82
82
  do {
83
83
  endp--;
84
84
  } while (endp > path && *endp == '/');
@@ -34,7 +34,6 @@
34
34
  * SUCH DAMAGE.
35
35
  */
36
36
 
37
- // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
38
37
  #ifdef _WIN32
39
38
  #pragma warning(disable:4101)
40
39
  #pragma warning(disable:4244)
@@ -144,7 +143,6 @@ typedef char Char;
144
143
  #define M_SET META('[')
145
144
  #define ismeta(c) (((c)&M_QUOTE) != 0)
146
145
 
147
- // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
148
146
  #ifdef _WIN32
149
147
  #define __P(protos) protos
150
148
  #define S_ISDIR(m) (((m) & (_S_IFMT)) == (_S_IFDIR))
@@ -386,7 +384,7 @@ globtilde(pattern, patbuf, patbuf_len, pglob)
386
384
  #ifdef HAVE_ISSETUGID
387
385
  if (issetugid() != 0 || (h = getenv("HOME")) == NULL) {
388
386
  #endif
389
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
387
+ #ifndef _WIN32
390
388
  if ((pwd = getpwuid(getuid())) == NULL)
391
389
  return pattern;
392
390
  else
@@ -404,7 +402,7 @@ globtilde(pattern, patbuf, patbuf_len, pglob)
404
402
  /*
405
403
  * Expand a ~user
406
404
  */
407
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
405
+ #ifndef _WIN32
408
406
  if ((pwd = getpwnam((char*) patbuf)) == NULL)
409
407
  return pattern;
410
408
  else
@@ -39,7 +39,6 @@ static char *rcsid = "$OpenBSD: strmode.c,v 1.3 1997/06/13 13:57:20 deraadt Exp
39
39
  #include <sys/stat.h>
40
40
  #include <string.h>
41
41
 
42
- // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
43
42
  #ifdef _WIN32
44
43
  #include "win32/types.h"
45
44
  #endif
@@ -57,7 +56,7 @@ strmode(mode, p)
57
56
  case S_IFCHR: /* character special */
58
57
  *p++ = 'c';
59
58
  break;
60
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
59
+ #ifndef _WIN32
61
60
  case S_IFBLK: /* block special */
62
61
  *p++ = 'b';
63
62
  break;
@@ -65,12 +64,12 @@ strmode(mode, p)
65
64
  case S_IFREG: /* regular */
66
65
  *p++ = '-';
67
66
  break;
68
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
67
+ #ifndef _WIN32
69
68
  case S_IFLNK: /* symbolic link */
70
69
  *p++ = 'l';
71
70
  break;
72
71
  #endif
73
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
72
+ #ifndef _WIN32
74
73
  case S_IFSOCK: /* socket */
75
74
  *p++ = 's';
76
75
  break;
@@ -90,7 +89,7 @@ strmode(mode, p)
90
89
  break;
91
90
  }
92
91
  /* usr */
93
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
92
+ #ifndef _WIN32
94
93
  if (mode & S_IRUSR)
95
94
  *p++ = 'r';
96
95
  else
@@ -98,7 +97,7 @@ strmode(mode, p)
98
97
  #else
99
98
  *p++ = '-';
100
99
  #endif
101
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
100
+ #ifndef _WIN32
102
101
  if (mode & S_IWUSR)
103
102
  *p++ = 'w';
104
103
  else
@@ -106,7 +105,7 @@ strmode(mode, p)
106
105
  #else
107
106
  *p++ = '-';
108
107
  #endif
109
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
108
+ #ifndef _WIN32
110
109
  switch (mode & (S_IXUSR | S_ISUID)) {
111
110
  case 0:
112
111
  *p++ = '-';
@@ -125,7 +124,7 @@ strmode(mode, p)
125
124
  *p++ = '-';
126
125
  #endif
127
126
  /* group */
128
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
127
+ #ifndef _WIN32
129
128
  if (mode & S_IRGRP)
130
129
  *p++ = 'r';
131
130
  else
@@ -133,7 +132,7 @@ strmode(mode, p)
133
132
  #else
134
133
  *p++ = '-';
135
134
  #endif
136
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
135
+ #ifndef _WIN32
137
136
  if (mode & S_IWGRP)
138
137
  *p++ = 'w';
139
138
  else
@@ -141,7 +140,7 @@ strmode(mode, p)
141
140
  #else
142
141
  *p++ = '-';
143
142
  #endif
144
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
143
+ #ifndef _WIN32
145
144
  switch (mode & (S_IXGRP | S_ISGID)) {
146
145
  case 0:
147
146
  *p++ = '-';
@@ -160,7 +159,7 @@ strmode(mode, p)
160
159
  *p++ = '-';
161
160
  #endif
162
161
  /* other */
163
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
162
+ #ifndef _WIN32
164
163
  if (mode & S_IROTH)
165
164
  *p++ = 'r';
166
165
  else
@@ -168,7 +167,7 @@ strmode(mode, p)
168
167
  #else
169
168
  *p++ = '-';
170
169
  #endif
171
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
170
+ #ifndef _WIN32
172
171
  if (mode & S_IWOTH)
173
172
  *p++ = 'w';
174
173
  else
@@ -176,7 +175,7 @@ strmode(mode, p)
176
175
  #else
177
176
  *p++ = '-';
178
177
  #endif
179
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
178
+ #ifndef _WIN32
180
179
  switch (mode & (S_IXOTH | S_ISVTX)) {
181
180
  case 0:
182
181
  *p++ = '-';
@@ -10,7 +10,6 @@
10
10
  ** University of Illinois at Urbana-Champaign
11
11
  */
12
12
 
13
- // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
14
13
  #ifdef _WIN32
15
14
  #pragma warning(disable:4101)
16
15
  #endif
@@ -117,7 +116,7 @@ tar_append_file(TAR *t, char *realname, char *savename)
117
116
  if (libtar_hash_add(t->h, td) == -1)
118
117
  return -1;
119
118
  }
120
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
119
+ #ifndef _WIN32
121
120
  libtar_hashptr_reset(&hp);
122
121
  if (libtar_hash_getkey(td->td_h, &hp, &(s.st_ino),
123
122
  (libtar_matchfunc_t)ino_match) != 0)
@@ -147,7 +146,7 @@ tar_append_file(TAR *t, char *realname, char *savename)
147
146
  }
148
147
  #endif /* #ifndef _WIN32 */
149
148
 
150
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
149
+ #ifndef _WIN32
151
150
  /* check if it's a symlink */
152
151
  if (TH_ISSYM(t))
153
152
  {
@@ -224,8 +223,6 @@ tar_append_regfile(TAR *t, char *realname)
224
223
  int i, j;
225
224
  size_t size;
226
225
 
227
- // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
228
- //filefd = open(realname, O_RDONLY);
229
226
  filefd = open(realname, O_RDONLY
230
227
  #ifdef O_BINARY
231
228
  | O_BINARY
@@ -47,7 +47,7 @@ uid_t
47
47
  th_get_uid(TAR *t)
48
48
  {
49
49
  int uid;
50
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
50
+ #ifndef _WIN32
51
51
  struct passwd *pw;
52
52
 
53
53
  pw = getpwnam(t->th_buf.uname);
@@ -65,7 +65,7 @@ gid_t
65
65
  th_get_gid(TAR *t)
66
66
  {
67
67
  int gid;
68
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
68
+ #ifndef _WIN32
69
69
  struct group *gr;
70
70
 
71
71
  gr = getgrnam(t->th_buf.gname);
@@ -89,7 +89,7 @@ th_get_mode(TAR *t)
89
89
  {
90
90
  switch (t->th_buf.typeflag)
91
91
  {
92
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
92
+ #ifndef _WIN32
93
93
  case SYMTYPE:
94
94
  mode |= S_IFLNK;
95
95
  break;
@@ -97,7 +97,7 @@ th_get_mode(TAR *t)
97
97
  case CHRTYPE:
98
98
  mode |= S_IFCHR;
99
99
  break;
100
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
100
+ #ifndef _WIN32
101
101
  case BLKTYPE:
102
102
  mode |= S_IFBLK;
103
103
  break;
@@ -105,7 +105,7 @@ th_get_mode(TAR *t)
105
105
  case DIRTYPE:
106
106
  mode |= S_IFDIR;
107
107
  break;
108
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
108
+ #ifndef _WIN32
109
109
  case FIFOTYPE:
110
110
  mode |= S_IFIFO;
111
111
  break;
@@ -10,7 +10,6 @@
10
10
  ** University of Illinois at Urbana-Champaign
11
11
  */
12
12
 
13
- // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
14
13
  #ifdef _WIN32
15
14
  #pragma warning(disable:4244)
16
15
  #endif
@@ -42,15 +41,11 @@ th_finish(TAR *t)
42
41
  strncpy(t->th_buf.magic, TMAGIC, TMAGLEN);
43
42
  }
44
43
 
45
- // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
46
44
  for (i = 0; i < T_BLOCKSIZE; i++) {
47
- //sum += ((char *)(&(t->th_buf)))[i];
48
45
  sum += ((unsigned char *)(&(t->th_buf)))[i];
49
46
  }
50
47
  for (i = 0; i < 8; i++)
51
48
  sum += (' ' - t->th_buf.chksum[i]);
52
- // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
53
- //int_to_oct(sum, t->th_buf.chksum, 8);
54
49
  snprintf(t->th_buf.chksum, 8, "%06lo", (unsigned long)(sum));
55
50
  t->th_buf.chksum[6] = 0;
56
51
  t->th_buf.chksum[7] = ' ';
@@ -69,7 +64,7 @@ th_set_type(TAR *t, mode_t mode)
69
64
  t->th_buf.typeflag = DIRTYPE;
70
65
  if (S_ISCHR(mode))
71
66
  t->th_buf.typeflag = CHRTYPE;
72
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
67
+ #ifndef _WIN32
73
68
  if (S_ISBLK(mode))
74
69
  t->th_buf.typeflag = BLKTYPE;
75
70
  #endif
@@ -130,7 +125,7 @@ th_set_path(TAR *t, char *pathname)
130
125
  void
131
126
  th_set_link(TAR *t, char *linkname)
132
127
  {
133
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
128
+ #ifndef _WIN32
134
129
  #ifdef DEBUG
135
130
  printf("==> th_set_link(th, linkname=\"%s\")\n", linkname);
136
131
  #endif
@@ -158,7 +153,7 @@ th_set_link(TAR *t, char *linkname)
158
153
  void
159
154
  th_set_device(TAR *t, dev_t device)
160
155
  {
161
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
156
+ #ifndef _WIN32
162
157
  #ifdef DEBUG
163
158
  printf("th_set_device(): major = %d, minor = %d\n",
164
159
  major(device), minor(device));
@@ -173,7 +168,7 @@ th_set_device(TAR *t, dev_t device)
173
168
  void
174
169
  th_set_user(TAR *t, uid_t uid)
175
170
  {
176
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
171
+ #ifndef _WIN32
177
172
  struct passwd *pw;
178
173
 
179
174
  pw = getpwuid(uid);
@@ -189,7 +184,7 @@ th_set_user(TAR *t, uid_t uid)
189
184
  void
190
185
  th_set_group(TAR *t, gid_t gid)
191
186
  {
192
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
187
+ #ifndef _WIN32
193
188
  struct group *gr;
194
189
 
195
190
  gr = getgrgid(gid);
@@ -205,15 +200,13 @@ th_set_group(TAR *t, gid_t gid)
205
200
  void
206
201
  th_set_mode(TAR *t, mode_t fmode)
207
202
  {
208
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
203
+ #ifndef _WIN32
209
204
  if (S_ISSOCK(fmode))
210
205
  {
211
206
  fmode &= ~S_IFSOCK;
212
207
  fmode |= S_IFIFO;
213
208
  }
214
209
  #endif
215
- // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
216
- //int_to_oct(fmode, (t)->th_buf.mode, 8);
217
210
  int_to_oct((fmode & 0xFFF), (t)->th_buf.mode, 8);
218
211
  }
219
212
 
@@ -125,17 +125,17 @@ tar_extract_file(TAR *t, char *realname)
125
125
  if (i == 1)
126
126
  i = 0;
127
127
  }
128
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
128
+ #ifndef _WIN32
129
129
  else if (TH_ISLNK(t))
130
130
  i = tar_extract_hardlink(t, realname);
131
131
  #endif
132
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
132
+ #ifndef _WIN32
133
133
  else if (TH_ISSYM(t))
134
134
  i = tar_extract_symlink(t, realname);
135
135
  #endif
136
136
  else if (TH_ISCHR(t))
137
137
  i = tar_extract_chardev(t, realname);
138
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
138
+ #ifndef _WIN32
139
139
  else if (TH_ISBLK(t))
140
140
  i = tar_extract_blockdev(t, realname);
141
141
  #endif
@@ -281,7 +281,6 @@ tar_extract_regfile(TAR *t, char *realname)
281
281
  return 0;
282
282
  }
283
283
 
284
- // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
285
284
  int tar_extract_function(TAR *t, void *data, int (*f)(char *b, int l, void *d)) {
286
285
  size_t size;
287
286
  int i, k;
@@ -343,7 +342,7 @@ tar_skip_regfile(TAR *t)
343
342
  int
344
343
  tar_extract_hardlink(TAR * t, char *realname)
345
344
  {
346
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
345
+ #ifndef _WIN32
347
346
  char *filename;
348
347
  char *linktgt = NULL;
349
348
  linkname_t *lnp;
@@ -399,7 +398,7 @@ tar_extract_hardlink(TAR * t, char *realname)
399
398
  int
400
399
  tar_extract_symlink(TAR *t, char *realname)
401
400
  {
402
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
401
+ #ifndef _WIN32
403
402
  char *filename;
404
403
  char buf[T_BLOCKSIZE];
405
404
 
@@ -498,7 +497,7 @@ tar_extract_chardev(TAR *t, char *realname)
498
497
  int
499
498
  tar_extract_blockdev(TAR *t, char *realname)
500
499
  {
501
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
500
+ #ifndef _WIN32
502
501
  mode_t mode;
503
502
  unsigned long devmaj, devmin;
504
503
  char *filename;
@@ -31,7 +31,7 @@ static long libtar_open(const char *pathname, int oflags, int mode) {
31
31
  return open(pathname, oflags, mode);
32
32
  }
33
33
 
34
- static long libtar_close(long fd) {
34
+ static int libtar_close(long fd) {
35
35
  return close((int) fd);
36
36
  }
37
37
 
@@ -15,7 +15,6 @@
15
15
 
16
16
  #include <libtar.h>
17
17
 
18
- // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
19
18
  #ifdef _WIN32
20
19
 
21
20
  #include <direct.h>
@@ -42,6 +41,4 @@
42
41
  #define mkfifo(p, m) (0)
43
42
  #define mknod(p, m, d) (0)
44
43
  #define snprintf(s, n, f, ...) do { _snprintf((s), (n), (f), __VA_ARGS__); (s)[(n) - 1] = '\0'; } while(0)
45
-
46
- int tarruby_stat(const char *path, struct stat *buf);
47
44
  #endif
@@ -19,7 +19,6 @@
19
19
 
20
20
  #include <libtar_listhash.h>
21
21
 
22
- // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
23
22
  #ifdef _WIN32
24
23
  #include "win32/types.h"
25
24
  #define S_ISDIR(m) (((m) & (_S_IFMT)) == (_S_IFDIR))
@@ -230,7 +229,6 @@ void th_finish(TAR *t);
230
229
  /* sequentially extract next file from t */
231
230
  int tar_extract_file(TAR *t, char *realname);
232
231
 
233
- // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
234
232
  int tar_extract_function(TAR *t, void *data, int (*f)(char *b, int l, void *d));
235
233
 
236
234
  /* extract different file types */
@@ -283,9 +281,6 @@ int th_crc_calc(TAR *t);
283
281
  int oct_to_int(char *oct);
284
282
 
285
283
  /* integer to NULL-terminated string-octal conversion */
286
- // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
287
- //#define int_to_oct(num, oct, octlen) \
288
- // snprintf((oct), (octlen), "%*lo ", (octlen) - 2, (unsigned long)(num))
289
284
  #define int_to_oct(num, oct, octlen) \
290
285
  snprintf((oct), (octlen), "%0*lo", (octlen) - 1, (unsigned long)(num))
291
286
 
@@ -64,7 +64,7 @@ th_print_long_ls(TAR *t)
64
64
  {
65
65
  char *filename;
66
66
  char modestring[12];
67
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
67
+ #ifndef _WIN32
68
68
  struct passwd *pw;
69
69
  struct group *gr;
70
70
  #endif
@@ -85,7 +85,7 @@ th_print_long_ls(TAR *t)
85
85
  #endif
86
86
 
87
87
  uid = th_get_uid(t);
88
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
88
+ #ifndef _WIN32
89
89
  pw = getpwuid(uid);
90
90
  if (pw == NULL)
91
91
  snprintf(username, sizeof(username), "%d", uid);
@@ -96,7 +96,7 @@ th_print_long_ls(TAR *t)
96
96
  #endif
97
97
 
98
98
  gid = th_get_gid(t);
99
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
99
+ #ifndef _WIN32
100
100
  gr = getgrgid(gid);
101
101
  if (gr == NULL)
102
102
  snprintf(groupname, sizeof(groupname), "%d", gid);
@@ -150,9 +150,6 @@ oct_to_int(char *oct)
150
150
  void
151
151
  int_to_oct_nonull(int num, char *oct, size_t octlen)
152
152
  {
153
- // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
154
- //snprintf(oct, octlen, "%*lo", octlen - 1, (unsigned long)num);
155
- //oct[octlen - 1] = ' ';
156
153
  snprintf(oct, octlen, "%0*lo", octlen - 1, (unsigned long)num);
157
154
  oct[octlen - 1] = 0;
158
155
  }
@@ -21,7 +21,6 @@
21
21
  # include <string.h>
22
22
  #endif
23
23
 
24
-
25
24
  int
26
25
  tar_extract_glob(TAR *t, char *globname, char *prefix)
27
26
  {
@@ -46,8 +45,6 @@ tar_extract_glob(TAR *t, char *globname, char *prefix)
46
45
  snprintf(buf, sizeof(buf), "%s/%s", prefix, filename);
47
46
  else
48
47
  strlcpy(buf, filename, sizeof(buf));
49
- // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
50
- //if (tar_extract_file(t, filename) != 0)
51
48
  if (tar_extract_file(t, buf) != 0) {
52
49
  free(filename);
53
50
  return -1;
@@ -106,8 +103,8 @@ tar_append_tree(TAR *t, char *realdir, char *savedir)
106
103
  struct dirent *dent;
107
104
  DIR *dp;
108
105
  struct stat s;
109
- #ifdef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
110
- int errorp = 0;
106
+ #if defined(_WIN32)
107
+ int errorp = 0;
111
108
  #endif
112
109
 
113
110
  #ifdef DEBUG
@@ -122,14 +119,14 @@ tar_append_tree(TAR *t, char *realdir, char *savedir)
122
119
  puts(" tar_append_tree(): done with tar_append_file()...");
123
120
  #endif
124
121
 
125
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
122
+ #ifndef _WIN32
126
123
  dp = opendir(realdir);
127
124
  #else
128
125
  dp = opendir0(realdir, &errorp);
129
126
  #endif
130
127
  if (dp == NULL)
131
128
  {
132
- #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
129
+ #ifndef _WIN32
133
130
  if (errno == ENOTDIR)
134
131
  return 0;
135
132
  #else
@@ -8,6 +8,7 @@
8
8
  #endif
9
9
  #include "libtar.h"
10
10
  #include "ruby.h"
11
+ #include "rubysig.h"
11
12
 
12
13
  #ifndef RSTRING_PTR
13
14
  #define RSTRING_PTR(s) (RSTRING(s)->ptr)
@@ -32,7 +33,7 @@
32
33
 
33
34
  #define INT2TIME(i) rb_funcall(rb_cTime, rb_intern("at"), 1, INT2NUM(i))
34
35
 
35
- #define VERSION "0.1.2"
36
+ #define VERSION "0.1.3"
36
37
 
37
38
  static VALUE Tar;
38
39
  static VALUE Error;
@@ -275,6 +276,7 @@ static VALUE tarruby_append_tree(int argc, VALUE *argv, VALUE self) {
275
276
  VALUE realdir, savedir;
276
277
  struct tarruby_tar *p_tar;
277
278
  char *s_realdir, *s_savedir = NULL;
279
+ int result = -1;
278
280
 
279
281
  rb_scan_args(argc, argv, "11", &realdir, &savedir);
280
282
  Check_Type(realdir, T_STRING);
@@ -289,7 +291,11 @@ static VALUE tarruby_append_tree(int argc, VALUE *argv, VALUE self) {
289
291
 
290
292
  Data_Get_Struct(self, struct tarruby_tar, p_tar);
291
293
 
292
- if (tar_append_tree(p_tar->tar, s_realdir, s_savedir) != 0) {
294
+ TRAP_BEG;
295
+ result = tar_append_tree(p_tar->tar, s_realdir, s_savedir);
296
+ TRAP_END;
297
+
298
+ if (result != 0) {
293
299
  rb_raise(Error, "Append tree failed: %s", strerror(errno));
294
300
  }
295
301
 
@@ -343,6 +349,7 @@ static VALUE tarruby_extract_glob(int argc, VALUE *argv, VALUE self) {
343
349
  VALUE globname, prefix;
344
350
  struct tarruby_tar *p_tar;
345
351
  char *s_globname, *s_prefix = NULL;
352
+ int result = -1;
346
353
 
347
354
  rb_scan_args(argc, argv, "11", &globname, &prefix);
348
355
  Check_Type(globname, T_STRING);
@@ -355,7 +362,11 @@ static VALUE tarruby_extract_glob(int argc, VALUE *argv, VALUE self) {
355
362
 
356
363
  Data_Get_Struct(self, struct tarruby_tar, p_tar);
357
364
 
358
- if (tar_extract_glob(p_tar->tar, s_globname, s_prefix) != 0) {
365
+ TRAP_BEG;
366
+ result = tar_extract_glob(p_tar->tar, s_globname, s_prefix);
367
+ TRAP_END;
368
+
369
+ if (result != 0) {
359
370
  rb_raise(Error, "Extract archive failed: %s", strerror(errno));
360
371
  }
361
372
 
@@ -369,6 +380,7 @@ static VALUE tarruby_extract_all(int argc, VALUE *argv, VALUE self) {
369
380
  VALUE prefix;
370
381
  struct tarruby_tar *p_tar;
371
382
  char *s_prefix = NULL;
383
+ int result = -1;
372
384
 
373
385
  rb_scan_args(argc, argv, "01", &prefix);
374
386
 
@@ -379,7 +391,11 @@ static VALUE tarruby_extract_all(int argc, VALUE *argv, VALUE self) {
379
391
 
380
392
  Data_Get_Struct(self, struct tarruby_tar, p_tar);
381
393
 
382
- if (tar_extract_all(p_tar->tar, s_prefix) != 0) {
394
+ TRAP_BEG;
395
+ result = tar_extract_all(p_tar->tar, s_prefix);
396
+ TRAP_END;
397
+
398
+ if (result != 0) {
383
399
  rb_raise(Error, "Extract archive failed: %s", strerror(errno));
384
400
  }
385
401
 
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.2
4
+ version: 0.1.3
5
5
  platform: ruby
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-13 00:00:00 +09:00
12
+ date: 2008-09-14 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -61,6 +61,7 @@ files:
61
61
  - ext/libtar/configure
62
62
  - ext/libtar/configure.ac
63
63
  - ext/libtar/COPYRIGHT
64
+ - ext/libtar/Copyright.txt
64
65
  - ext/libtar/doc
65
66
  - ext/libtar/doc/Makefile.in
66
67
  - ext/libtar/doc/tar_append_file.3