- /* makepath will ignore the final path component, so make sure
- dirnames have a trailing slash */
-
- if (fullname[strlen(fullname)-1] != '/')
- strcat(fullname,"/");
- if (makepath(fullname)){
- fprintf(stderr, "Error: cannot create directory %s. Exiting.\n",
- fullname);
- exit(-2);
- }
- continue;
- } else { /*file */
- in_block = 1;
- if (outfile){
- if (fclose(outfile)){
- fprintf(stderr,"Error: cannot close file %s. Exiting.\n",
- fullname);
- exit(-2);
- }
- outfile = (FILE*)0;
- }
-
- if ( !(outfile = fopen(fullname,"wb"))){
- /*try creating the directory, maybe it's not there */
- if (makepath(fullname)){
- fprintf(stderr,"Error: cannot create file %s. Exiting.\n",
- fullname);
- exit(-2);
- }
- /* now try again to open the file */
- if (!(outfile = fopen(fullname,"wb"))){
- fprintf(stderr,"Error: cannot create file %s. Exiting.\n",
- fullname);
- exit(-2);
- }
+ /* makepath will ignore the final path component, so make sure
+ dirnames have a trailing slash */
+
+ if (fullname[strlen (fullname)-1] != '/')
+ strcat (fullname, "/");
+ if (makepath (fullname))
+ {
+ fprintf (stderr, "Error: cannot create directory %s. Exiting.\n",
+ fullname);
+ exit (-2);
+ }
+ continue;
+ }
+ else
+ { /*file */
+ in_block = 1;
+ if (outfile)
+ {
+ if (fclose (outfile))
+ {
+ fprintf (stderr, "Error: cannot close file %s. Exiting.\n",
+ fullname);
+ exit (-2);
+ }
+ outfile = (FILE*)0;
+ }
+
+ if (!(outfile = fopen (fullname, "wb")))
+ {
+ /*try creating the directory, maybe it's not there */
+ if (makepath (fullname))
+ {
+ fprintf (stderr, "Error: cannot create file %s. Exiting.\n",
+ fullname);
+ exit (-2);
+ }
+ /* now try again to open the file */
+ if (!(outfile = fopen (fullname, "wb")))
+ {
+ fprintf (stderr, "Error: cannot create file %s. Exiting.\n",
+ fullname);
+ exit (-2);
+ }
+ }
+
+ strncpy (osize, block+124, 12);
+ osize[12] = '\0';
+ size = octal (osize);
+ if (size<0)
+ {
+ fprintf (stderr, "Error: invalid size in tar header. Exiting.\n");
+ exit (-2);
+ }
+ if (size==0) /* file of size 0 is done */
+ in_block = 0;
+ }