Branch Coverage

extract.c
Criterion Covered Total %
branch 58 152 38.1


line true false branch
37 0 147 if (name_len == 0) return 0;
38 0 147 if (name[0] == '/') return 0; /* absolute */
39 284 145 while (i < name_len) {
41 2373 143 while (i < name_len && name[i] != '/') i++;
2232 141 while (i < name_len && name[i] != '/') i++;
43 2 282 if (comp == 2 && name[start] == '.' && name[start + 1] == '.') return 0;
2 0 if (comp == 2 && name[start] == '.' && name[start + 1] == '.') return 0;
2 0 if (comp == 2 && name[start] == '.' && name[start + 1] == '.') return 0;
44 143 139 if (i < name_len) i++; /* skip the '/' */
59 0 157 if (n == 0) return 0;
60 0 157 if (n >= sizeof buf) { errno = ENAMETOOLONG; return -1; }
63 4004 157 for (i = 0; i <= n; i++) {
64 3395 609 if (buf[i] == '/' || buf[i] == '\0') {
157 3238 if (buf[i] == '/' || buf[i] == '\0') {
65 157 609 if (i == 0) continue; /* leading "/" */
69 37 572 if (stat(buf, &st) < 0) {
70 0 37 if (errno != ENOENT) { buf[i] = saved; return -1; }
71 37 0 if (mkdir(buf, mode ? mode : 0755) < 0 && errno != EEXIST) {
0 37 if (mkdir(buf, mode ? mode : 0755) < 0 && errno != EEXIST) {
0 0 if (mkdir(buf, mode ? mode : 0755) < 0 && errno != EEXIST) {
75 0 572 } else if (!S_ISDIR(st.st_mode)) {
90 144 0 if (!slash || slash == path) return 0; /* no parent or "/x" */
0 144 if (!slash || slash == path) return 0; /* no parent or "/x" */
93 0 144 if (parent_len >= sizeof buf) { errno = ENAMETOOLONG; return -1; }
106 2 0 if (archive_mkpath(out_path, mode ? (mode & 07777) : 0755) < 0) return -1;
0 2 if (archive_mkpath(out_path, mode ? (mode & 07777) : 0755) < 0) return -1;
107 2 0 if (mode) {
111 0 2 if (chmod(out_path, mode & 07777) < 0) return -1;
120 0 2 if (lstat(out_path, &st) == 0 && S_ISLNK(st.st_mode)) {
0 0 if (lstat(out_path, &st) == 0 && S_ISLNK(st.st_mode)) {
123 0 2 if (symlink(target, out_path) < 0) return -1;
134 84 0 if (e->mode) {
135 0 84 if (fchmod(fd, e->mode & 07777) < 0) return -1;
137 84 0 if (apply_xattrs && e->xattrs && e->xattr_count > 0) {
0 84 if (apply_xattrs && e->xattrs && e->xattr_count > 0) {
0 0 if (apply_xattrs && e->xattrs && e->xattr_count > 0) {
138 0 0 if (archive_apply_xattrs(fd, e->xattrs, e->xattr_count) < 0) return -1;
146 0 0 if (e->mode) {
147 0 0 if (chmod(path, e->mode & 07777) < 0) return -1;
149 0 0 if (e->mtime) {
153 0 0 if (utime(path, &t) < 0) return -1;
169 0 247 if (n < 0) return -1;
170 84 163 if (n == 0) break; /* end of entry */
172 163 163 while (put < (size_t)n) {
174 0 163 if (w < 0) {
175 0 0 if (errno == EINTR) continue;
198 84 0 if (errstage) *errstage = NULL;
201 84 0 e->mode ? (mode_t)(e->mode & 07777) : (mode_t)0644);
202 0 84 if (fd < 0) {
203 0 0 if (errstage) *errstage = "open";
207 0 84 if (archive_write_entry_data(aTHX_ plugin, cursor, fd) < 0) {
208 0 0 if (errstage) *errstage = "write";
216 0 84 if (archive_apply_metadata_fd(fd, e, apply_xattrs) < 0) {
217 0 0 if (errstage) *errstage = "chmod_or_xattr";
224 0 84 if (close(fd) < 0) {
225 0 0 if (errstage) *errstage = "close";
229 4 80 if (e->mtime) {
233 0 4 if (utime(out_path, &t) < 0) {
234 0 0 if (errstage) *errstage = "utime";
251 0 0 if (errstage) *errstage = NULL;
254 0 0 e->mode ? (mode_t)(e->mode & 07777) : (mode_t)0644);
255 0 0 if (fd < 0) {
256 0 0 if (errstage) *errstage = "open";
260 0 0 if (content_len > 0 && content) {
0 0 if (content_len > 0 && content) {
262 0 0 while (put < content_len) {
264 0 0 if (w < 0) {
265 0 0 if (errno == EINTR) continue;
266 0 0 if (errstage) *errstage = "write";
277 0 0 if (archive_apply_metadata_fd(fd, e, apply_xattrs) < 0) {
278 0 0 if (errstage) *errstage = "chmod_or_xattr";
285 0 0 if (close(fd) < 0) {
286 0 0 if (errstage) *errstage = "close";
290 0 0 if (e->mtime) {
294 0 0 if (utime(out_path, &t) < 0) {
295 0 0 if (errstage) *errstage = "utime";