---
name: "archive_write_fail"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/archive_write_close"
---

# archive\_write\_fail(3)

functions for creating archives

Part of [archive\_write\_close(3)](/archive_write_close/3.md).

## 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)
