/* Buffer management for tar.
Copyright (C) 1988, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001,
- 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
Written by John Gilmore, on 1985-08-25.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2, or (at your option) any later
+ Free Software Foundation; either version 3, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but
#include <closeout.h>
#include <fnmatch.h>
-#include <getline.h>
#include <human.h>
#include <quotearg.h>
{
struct zip_magic const *p;
bool sfr;
-
+ bool short_file = false;
+
/* Prepare global data needed for find_next_block: */
record_end = record_start; /* set up for 1st record = # 0 */
sfr = read_full_records;
read_full_records = true; /* Suppress fatal error on reading a partial
record */
- find_next_block ();
-
+ if (find_next_block () == 0)
+ short_file = true;
+
/* Restore global values */
read_full_records = sfr;
if (memcmp (record_start->buffer, p->magic, p->length) == 0)
return p->type;
+ if (short_file)
+ ERROR ((0, 0, _("This does not look like a tar archive")));
+
return ct_none;
}
}
static void
-do_checkpoint (bool write)
+do_checkpoint (bool do_write)
{
if (checkpoint_option && !(++checkpoint % checkpoint_option))
{
break;
case checkpoint_text:
- if (write)
+ if (do_write)
/* TRANSLATORS: This is a ``checkpoint of write operation'',
*not* ``Writing a checkpoint''.
E.g. in Spanish ``Punto de comprobaci@'on de escritura'',
{
size_t status;
union block *header;
- int access;
+ enum access_mode acc;
switch (subcommand_option)
{
case APPEND_SUBCOMMAND:
case CAT_SUBCOMMAND:
case UPDATE_SUBCOMMAND:
- access = ACCESS_UPDATE;
+ acc = ACCESS_UPDATE;
break;
default:
- access = ACCESS_READ;
+ acc = ACCESS_READ;
break;
}
- if (!new_volume (access))
+ if (!new_volume (acc))
return true;
while ((status = rmtread (archive, record_start->buffer, record_size))