---
name: "tar_append_eof"
section: "3"
platform: "linux"
package: "libtar"
version: "1.2.20-8"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/tar_append_file"
---

# tar\_append\_eof(3)

append data to tar archives

Part of [tar\_append\_file(3)](/tar_append_file/3.md).

## NAME

tar\_append\_file, tar\_append\_eof, tar\_append\_regfile - append data to tar archives

## SYNOPSIS

**#include \<libtar.h\>**

**int tar\_append\_file(TAR \****t***, char \****realname***,** **char \****savename***);**

**int tar\_append\_regfile(TAR \****t***, char \****realname***);**

**int tar\_append\_eof(TAR \****t***);**

## VERSION

This man page documents version 1.2 of **libtar**.

## DESCRIPTION

The **tar\_append\_file**() function creates a tar file header block describing the file named by the *realname* argument, but with the encoded filename of *savename*.  It then sets the current header associated with the *TAR* handle *t* to the newly created header block, and writes this block to the tar archive associated with *t*.  If the file named by *realname* is a regular file (and is not encoded as a hard link), **tar\_append\_file**() will call **tar\_append\_regfile**() to append the contents of the file.

The **tar\_append\_regfile**() function appends the contents of a regular file to the tar archive associated with *t*.  Since this function is called by **tar\_append\_file**(), it should only be necessary for applications that construct and write the tar file header on their own.

The **tar\_append\_eof**() function writes an EOF marker (two blocks of all zeros) to the tar file associated with *t*.

## RETURN VALUES

On successful completion, these functions will return 0.  On failure, they will return -1 and set *errno* to an appropriate value.

## ERRORS

The **tar\_append\_\***() functions will fail if:

- **EINVAL**

  Less than **T\_BLOCKSIZE** bytes were written to the tar archive.

- **EINVAL**

  Less than **T\_BLOCKSIZE** bytes were read from the *realname* file.

They may also fail if any of the following functions fail: **lstat**(), **malloc**(), **open**(), **read**(), **th\_write**(), or the write function for the file type associated with the *TAR* handle *t*.

## SEE ALSO

[**read**(2)](/read/2.md), [**open**(2)](/open/2.md), [**lstat**(2)](/lstat/2.md), [**th\_write**(3)](/th_write/3.md)
