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

# th\_write(3)

read and write a file header block from a tar archive

Part of [th\_read(3)](/th_read/3.md).

## NAME

th\_read, th\_write - read and write a file header block from a tar archive

## SYNOPSIS

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

**int th\_read(TAR \****t***);**

**int th\_write(TAR \****t***);**

## VERSION

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

## DESCRIPTION

The **th\_read**() function reads the next block from the tar archive associated with the *TAR* handle *t*.  It then sets the current tar header associated with *t* to the contents of the block read.

The **th\_write**() function writes the contents of the current tar header associated with *t* to the tar archive associated with *t*.

## RETURN VALUE

On successful completion, **th\_read**() and **th\_write**() will return 0.  On failure, they will return -1 and set *errno* to an appropriate value.

On *EOF*, **th\_read**() will return 1.

## ERRORS

**th\_read**() and **th\_write**() will fail if:

- **EINVAL**

  Less than **T\_BLOCKSIZE** blocks were read or written.

## SEE ALSO

[**tar\_block\_read**(3)](/tar_block_read/3.md), [**tar\_block\_write**(3)](/tar_block_write/3.md)
