}
}
+/* acquire the next record from the buffer; user must call write_if_needed() */
+static char *get_record(void)
+{
+ char *p = block + offset;
+ memset(p, 0, RECORDSIZE);
+ offset += RECORDSIZE;
+ return p;
+}
+
/*
* The end of tar archives is marked by 1024 nul bytes and after that
* follows the rest of the block (if any).
if (size > RECORDSIZE)
die("tar-tree: extended header too big, wtf?");
write_header(NULL, 'x', NULL, NULL, headerfilename, 0100600, size);
- p = block + offset;
- memset(p, 0, RECORDSIZE);
- offset += RECORDSIZE;
+ p = get_record();
append_long(&p, size);
append_string(&p, " path=");
append_path(&p, is_dir, basepath, prefix, path);
{
char *p;
write_header(NULL, 'g', NULL, NULL, "pax_global_header", 0, 52);
- p = block + offset;
- memset(p, 0, RECORDSIZE);
- offset += RECORDSIZE;
+ p = get_record();
append_long(&p, 52); /* 2 + 9 + 40 + 1 */
append_string(&p, " comment=");
append_string(&p, sha1_to_hex(sha1));
write_extended_header(headerfilename, S_ISDIR(mode), basepath,
prefix, path, namelen);
- header = block + offset;
- memset(header, 0, RECORDSIZE);
- offset += RECORDSIZE;
+ header = get_record();
sprintf(header, "%s.data", sha1_hex);
} else {
- header = block + offset;
- memset(header, 0, RECORDSIZE);
- offset += RECORDSIZE;
- p = header;
+ p = header = get_record();
append_path(&p, S_ISDIR(mode), basepath, prefix, path);
}