- extract_file:
- if (head->header.linkflag == LF_SPARSE) {
- char *name;
- int namelen;
-
- /*
- * Kludge alert. NAME is assigned to header.name
- * because during the extraction, the space that
- * contains the header will get scribbled on, and
- * the name will get munged, so any error messages
- * that happen to contain the filename will look
- * REAL interesting unless we do this.
- */
- namelen = strlen(skipcrud+head->header.name);
- name = (char *) malloc((sizeof(char)) * namelen);
- bcopy(skipcrud+head->header.name, name, namelen);
- size = hstat.st_size;
- extract_sparse_file(fd, &size, hstat.st_size,
- name);
- }
- else
- for (size = hstat.st_size;
- size > 0;
- size -= written) {
-
-/* long offset,
- numbytes;*/
-
- if(f_multivol) {
- save_name=head->header.name;
- save_totsize=hstat.st_size;
- save_sizeleft=size;
- }
-
- /*
- * Locate data, determine max length
- * writeable, write it, record that
- * we have used the data, then check
- * if the write worked.
- */
- data = findrec()->charptr;
- if (data == NULL) { /* Check it... */
- msg("Unexpected EOF on archive file");
- break;
- }
- /*
- * JK - If the file is sparse, use the sparsearray
- * that we created before to lseek into the new
- * file the proper amount, and to see how many
- * bytes we want to write at that position.
- */
-/* if (head->header.linkflag == LF_SPARSE) {
- off_t pos;
-
- pos = lseek(fd, (off_t) sparsearray[sparse_ind].offset, 0);
- printf("%d at %d\n", (int) pos, sparse_ind);
- written = sparsearray[sparse_ind++].numbytes;
- } else*/
- written = endofrecs()->charptr - data;
- if (written > size)
- written = size;
- errno = 0;
- check = write(fd, data, written);
- /*
- * The following is in violation of strict
- * typing, since the arg to userec
- * should be a struct rec *. FIXME.
- */
- userec((union record *)(data + written - 1));
- if (check == written) continue;
- /*
- * Error in writing to file.
- * Print it, skip to next file in archive.
- */
- if(check<0)
- msg_perror("couldn't write to file %s",skipcrud+head->header.name);
- else
- msg("could only write %d of %d bytes to file %s",written,check,skipcrud+head->header.name);
- skip_file((long)(size - written));
- break; /* Still do the close, mod time, chmod, etc */
- }
+ extract_file:
+ if (head->header.linkflag == LF_SPARSE)
+ {
+ char *name;
+ int namelen;
+
+ /*
+ * Kludge alert. NAME is assigned to header.name
+ * because during the extraction, the space that
+ * contains the header will get scribbled on, and
+ * the name will get munged, so any error messages
+ * that happen to contain the filename will look
+ * REAL interesting unless we do this.
+ */
+ namelen = strlen (skipcrud + current_file_name) + 1;
+ name = (char *) ck_malloc ((sizeof (char)) * namelen);
+ bcopy (skipcrud + current_file_name, name, namelen);
+ size = hstat.st_size;
+ extract_sparse_file (fd, &size, hstat.st_size, name);
+ }
+ else
+ for (size = hstat.st_size;
+ size > 0;
+ size -= written)
+ {
+
+ /* long offset,
+ numbytes;*/
+
+ if (f_multivol)
+ {
+ save_name = current_file_name;
+ save_totsize = hstat.st_size;
+ save_sizeleft = size;
+ }
+
+ /*
+ * Locate data, determine max length
+ * writeable, write it, record that
+ * we have used the data, then check
+ * if the write worked.
+ */
+ data = findrec ()->charptr;
+ if (data == NULL)
+ { /* Check it... */
+ msg ("Unexpected EOF on archive file");
+ break;
+ }
+ /*
+ * JK - If the file is sparse, use the sparsearray
+ * that we created before to lseek into the new
+ * file the proper amount, and to see how many
+ * bytes we want to write at that position.
+ */
+ /* if (head->header.linkflag == LF_SPARSE) {
+ off_t pos;
+
+ pos = lseek(fd, (off_t) sparsearray[sparse_ind].offset, 0);
+ printf("%d at %d\n", (int) pos, sparse_ind);
+ written = sparsearray[sparse_ind++].numbytes;
+ } else*/
+ written = endofrecs ()->charptr - data;
+ if (written > size)
+ written = size;
+ errno = 0;
+ check = write (fd, data, written);
+ /*
+ * The following is in violation of strict
+ * typing, since the arg to userec
+ * should be a struct rec *. FIXME.
+ */
+ userec ((union record *) (data + written - 1));
+ if (check == written)
+ continue;
+ /*
+ * Error in writing to file.
+ * Print it, skip to next file in archive.
+ */
+ if (check < 0)
+ msg_perror ("couldn't write to file %s",
+ skipcrud + current_file_name);
+ else
+ msg ("could only write %d of %d bytes to file %s",
+ check, written, skipcrud + current_file_name);
+ skip_file ((long) (size - written));
+ break; /* Still do the close, mod time, chmod, etc */
+ }
+
+ if (f_multivol)
+ save_name = 0;
+
+ /* If writing to stdout, don't try to do anything
+ to the filename; it doesn't exist, or we don't
+ want to touch it anyway */
+ if (f_exstdout)
+ break;
+
+ /* if (head->header.isextended) {
+ register union record *exhdr;
+ register int i;
+
+ for (i = 0; i < 21; i++) {
+ long offset;
+
+ if (!exhdr->ext_hdr.sp[i].numbytes)
+ break;
+ offset = from_oct(1+12,
+ exhdr->ext_hdr.sp[i].offset);
+ written = from_oct(1+12,
+ exhdr->ext_hdr.sp[i].numbytes);
+ lseek(fd, offset, 0);
+ check = write(fd, data, written);
+ if (check == written) continue;
+
+ }
+
+
+ }*/
+ check = close (fd);
+ if (check < 0)
+ {
+ msg_perror ("Error while closing %s",
+ skipcrud + current_file_name);
+ }