From: Sergey Poznyakoff Date: Mon, 7 Nov 2005 02:48:51 +0000 (+0000) Subject: (dumpdir_size, get_gnu_dumpdir): New functions. X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=08a8d2dec63967653c7f54a1b4b7cb49c3c12679;p=chaz%2Ftar (dumpdir_size, get_gnu_dumpdir): New functions. (purge_directory): Use stat_info.dumpdir instead of getting its value explicitely. --- diff --git a/src/incremen.c b/src/incremen.c index b5eec8f..48de668 100644 --- a/src/incremen.c +++ b/src/incremen.c @@ -361,6 +361,20 @@ get_directory_contents (char *dir_name, dev_t device) return buffer; } +size_t +dumpdir_size (const char *p) +{ + size_t totsize = 0; + + while (*p) + { + size_t size = strlen (p) + 1; + totsize += size; + p += size; + } + return totsize + 1; +} + static FILE *listed_incremental_stream; @@ -617,43 +631,35 @@ write_directory_file (void) /* Restoration of incremental dumps. */ -/* Examine the directories under directory_name and delete any - files that were not there at the time of the back-up. */ void -purge_directory (char const *directory_name) +get_gnu_dumpdir () { - char *archive_dir; - char *current_dir; - char *cur, *arc; size_t size; size_t copied; union block *data_block; char *to; - - current_dir = savedir (directory_name); - - if (!current_dir) - { - /* The directory doesn't exist now. It'll be created. In any - case, we don't have to delete any files out of it. */ - - skip_member (); - return; - } - + char *archive_dir; + size = current_stat_info.stat.st_size; if (size != current_stat_info.stat.st_size) xalloc_die (); + archive_dir = xmalloc (size); to = archive_dir; + + set_next_block_after (current_header); + if (multi_volume_option) + { + assign_string (&save_name, current_stat_info.orig_file_name); + save_totsize = current_stat_info.stat.st_size; + } for (; size > 0; size -= copied) { + if (multi_volume_option) + save_sizeleft = size; data_block = find_next_block (); if (!data_block) - { - ERROR ((0, 0, _("Unexpected EOF in archive"))); - break; /* FIXME: What happens then? */ - } + ERROR ((1, 0, _("Unexpected EOF in archive"))); copied = available_space_after (data_block); if (copied > size) copied = size; @@ -662,10 +668,37 @@ purge_directory (char const *directory_name) set_next_block_after ((union block *) (data_block->buffer + copied - 1)); } + if (multi_volume_option) + assign_string (&save_name, 0); + + current_stat_info.stat.st_size = 0; /* For skip_member() and friends + to work correctly */ + current_stat_info.dumpdir = archive_dir; +} + + +/* Examine the directories under directory_name and delete any + files that were not there at the time of the back-up. */ +void +purge_directory (char const *directory_name) +{ + char *current_dir; + char *cur, *arc; + + current_dir = savedir (directory_name); + + if (!current_dir) + { + /* The directory doesn't exist now. It'll be created. In any + case, we don't have to delete any files out of it. */ + + skip_member (); + return; + } for (cur = current_dir; *cur; cur += strlen (cur) + 1) { - for (arc = archive_dir; *arc; arc += strlen (arc) + 1) + for (arc = current_stat_info.dumpdir; *arc; arc += strlen (arc) + 1) { arc++; if (!strcmp (arc, cur)) @@ -707,7 +740,6 @@ purge_directory (char const *directory_name) } free (current_dir); - free (archive_dir); } void