]> Dogcows Code - chaz/tar/commitdiff
(start_header): Store long file names
authorSergey Poznyakoff <gray@gnu.org.ua>
Wed, 3 Sep 2003 00:02:32 +0000 (00:02 +0000)
committerSergey Poznyakoff <gray@gnu.org.ua>
Wed, 3 Sep 2003 00:02:32 +0000 (00:02 +0000)
in "path" keyword of an extended header if in POSIX
mode.
(finish_header): print header before calling write_extended().

src/create.c

index 6f9f7e8ca291b7149251b68ef446857279cfe8e9..7b7e28f19aa54cebe68b41c4d643dc47c0190ff7 100644 (file)
@@ -469,10 +469,16 @@ start_header (const char *name, struct tar_stat_info *st)
   union block *header;
 
   name = safer_name_suffix (name, 0);
-
+  assign_string (&st->file_name, name);
+  
   if (sizeof header->header.name <= strlen (name))
-    write_long (name, GNUTYPE_LONGNAME);
-
+    {
+      if (archive_format == POSIX_FORMAT)
+       xheader_store ("path", st);
+      else
+       write_long (name, GNUTYPE_LONGNAME);
+    }
+  
   header = find_next_block ();
   memset (header->buffer, 0, sizeof (union block));
 
@@ -629,6 +635,22 @@ finish_header (union block *header, off_t block_ordinal)
   int sum;
   char *p;
 
+  /* Note: It is important to do this before the call to write_extended(),
+     so that the actual ustar header is printed */
+  if (verbose_option
+      && header->header.typeflag != GNUTYPE_LONGLINK
+      && header->header.typeflag != GNUTYPE_LONGNAME
+      && header->header.typeflag != XHDTYPE
+      && header->header.typeflag != XGLTYPE)
+    {
+      /* These globals are parameters to print_header, sigh.  */
+
+      current_header = header;
+      /* current_stat_info is already set up.  */
+      current_format = archive_format;
+      print_header (block_ordinal);
+    }
+
   header = write_extended (header, XHDTYPE);
   
   memcpy (header->header.chksum, CHKBLANKS, sizeof header->header.chksum);
@@ -651,18 +673,6 @@ finish_header (union block *header, off_t block_ordinal)
 
   uintmax_to_chars ((uintmax_t) sum, header->header.chksum, 7);
 
-  if (verbose_option
-      && header->header.typeflag != GNUTYPE_LONGLINK
-      && header->header.typeflag != GNUTYPE_LONGNAME)
-    {
-      /* These globals are parameters to print_header, sigh.  */
-
-      current_header = header;
-      /* current_stat_info is already set up.  */
-      current_format = archive_format;
-      print_header (block_ordinal);
-    }
-
   set_next_block_after (header);
 }
 \f
This page took 0.02422 seconds and 4 git commands to generate.