示例#1
0
文件: tape.c 项目: zg/tarsnap
/*
 * Print statistics relating to an archive or set of archives.
 */
void
tarsnap_mode_print_stats(struct bsdtar *bsdtar)
{
	TAPE_S * d;
	size_t i;

	/* Open the archive set for statistics purposes. */
	if ((d = statstape_open(bsdtar->machinenum,
	    bsdtar->cachedir)) == NULL)
		goto err1;

	/* Print statistics about the archive set. */
	if (statstape_printglobal(d, bsdtar->option_csv_filename))
		goto err2;

	if (bsdtar->ntapes == 0) {
		/* User only wanted global statistics. */
	} else if ((bsdtar->tapenames[0][0] == '*') &&
	    (bsdtar->tapenames[0][1] == '\0')) {
		/* User wants statistics on all archives. */
		if (statstape_printall(d, bsdtar->option_csv_filename))
			goto err2;
	} else {
		/* User wants statistics about specific archive(s). */
		for (i = 0; i < bsdtar->ntapes; i++) {
			switch (statstape_print(d, bsdtar->tapenames[i],
			    bsdtar->option_csv_filename)) {
			case 0:
				break;
			case 1:
				if (bsdtar->option_keep_going)
					break;
				/* FALLTHROUGH */
			default:
				goto err2;
			}
		}
	}

	/* We're done.  Close the archive set. */
	if (statstape_close(d))
		goto err1;

	/* Success! */
	return;

err2:
	statstape_close(d);
err1:
	/* Failure! */
	bsdtar_warnc(bsdtar, 0, "Error generating archive statistics");
	bsdtar->return_value = 1;
	return;
}
示例#2
0
文件: tape.c 项目: lornix/tarsnap
/*
 * Print statistics relating to an archive or set of archives.
 */
void
tarsnap_mode_print_stats(struct bsdtar *bsdtar)
{
	TAPE_S * d;
	size_t i;

	/* Open the archive set for statistics purposes. */
	if ((d = statstape_open(bsdtar->machinenum,
	    bsdtar->cachedir)) == NULL)
		goto err1;

	/* Print statistics about the archive set. */
	if (statstape_printglobal(d))
		goto err2;

	if (bsdtar->ntapes == 0) {
		/* User only wanted global statistics. */
	} else if ((bsdtar->tapenames[0][0] == '*') &&
	    (bsdtar->tapenames[0][1] == '\0')) {
		/* User wants statistics on all archives. */
		if (statstape_printall(d))
			goto err2;
	} else {
		/* User wants statistics about specific archive(s). */
		for (i = 0; i < bsdtar->ntapes; i++) {
			if (statstape_print(d, bsdtar->tapenames[i]))
				goto err2;
		}
	}

	/* We're done.  Close the archive set. */
	if (statstape_close(d))
		goto err1;

	/* Success! */
	return;

err2:
	statstape_close(d);
err1:
	/* Failure! */
	bsdtar_warnc(bsdtar, 0, "Error generating archive statistics");
	exit(1);
}