Esempio n. 1
0
/* close tarfile handle */
int
tar_close(TAR *t)
{
	int i;

	i = (*(t->type->closefunc))(t->fd);

	if (t->h != NULL)
		libtar_hash_free(t->h, ((t->oflags & O_ACCMODE) == O_RDONLY
					? free
					: (libtar_freefunc_t)tar_dev_free));
	free(t);

	return i;
}
Esempio n. 2
0
/* close tarfile handle */
int
tar_close(TAR *t)
{
	int i;

	/* Demote modified */
	//i = (*(t->type->closefunc))(t->fd);
	i = (*(t->type->closefuncx))(t);
	if (&default_type != t->type) {
		free(t->type);
	}

	if (t->h != NULL)
		libtar_hash_free(t->h, ((t->oflags & O_ACCMODE) == O_RDONLY
					? free
					: (libtar_freefunc_t)tar_dev_free));
	free(t);

	return i;
}
Esempio n. 3
0
/* open a new tarfile handle */
int
tar_open(TAR **t, const char *pathname, tartype_t *type,
	 int oflags, int mode, int options)
{
	if (tar_init(t, pathname, type, oflags, mode, options) == -1)
		return -1;

	if ((options & TAR_NOOVERWRITE) && (oflags & O_CREAT))
		oflags |= O_EXCL;

#ifdef O_BINARY
	oflags |= O_BINARY;
#endif

	(*t)->fd = (*((*t)->type->openfunc))(pathname, oflags, mode);
	if ((*t)->fd == -1)
	{
		libtar_hash_free((*t)->h, NULL);
		free(*t);
		return -1;
	}

	return 0;
}
Esempio n. 4
0
/* free memory associated with a tar_dev_t */
void
tar_dev_free(tar_dev_t *tdp)
{
	libtar_hash_free(tdp->td_h, free);
	free(tdp);
}