---
name: "archive_write_free"
section: "3"
platform: "linux"
package: "libarchive"
version: "3.8.11-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "freebsd", "macos"]
url: "https://new.carta.tech/archive_write_free"
---

# archive\_write\_free(3)

functions for creating archives

## NAME

**archive\_write\_fail**, **archive\_write\_close**, **archive\_write\_finish**, **archive\_write\_free** – functions for creating archives

## LIBRARY

Streaming Archive Library (libarchive, -larchive)

## SYNOPSIS

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

*int*\

**archive\_write\_fail**(*struct archive \**);

*int*\

**archive\_write\_close**(*struct archive \**);

*int*\

**archive\_write\_finish**(*struct archive \**);

*int*\

**archive\_write\_free**(*struct archive \**);

## DESCRIPTION

- **archive\_write\_fail**()

  Always returns **ARCHIVE\_FATAL**. This marks the archive object as being unusable; after calling this function, the only call that can succeed is **archive\_write\_free**() to release the resources. This can be used to speed recovery when the archive creation must be aborted. Note that the created archive is likely to be malformed in this case;

- **archive\_write\_close**()

  Complete the archive and invoke the close callback.

- **archive\_write\_finish**()

  This is a deprecated synonym for **archive\_write\_free**().

- **archive\_write\_free**()

  Invokes **archive\_write\_close**() if necessary, then releases all resources. If you need detailed information about **archive\_write\_close**() failures, you should be careful to call it separately, as you cannot obtain error information after **archive\_write\_free**() returns.

## RETURN VALUES

These functions return **ARCHIVE\_OK** on success, or **ARCHIVE\_FATAL**.

## ERRORS

Detailed error codes and textual descriptions are available from the **archive\_errno**() and **archive\_error\_string**() functions.

## SEE ALSO

[tar(1)](/tar/1.md), [archive\_write\_set\_options(3)](/archive_write_set_options/3.md), [libarchive(3)](/libarchive/3.md), [cpio(5)](/cpio/5.md), [mtree(5)](/mtree/5.md), [tar(5)](/tar/5.md)
