---
name: "af_files"
section: "3"
platform: "linux"
package: "atfs-dev"
version: "1.4pl6-15+b1"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/af_files"
---

# af\_files(3)

AtFS file system operations

## NAME

af\_crkey, af\_open, af\_close, af\_rm, af\_establish, af\_restore - AtFS file system operations

## SYNOPSIS

\#include \<stdio.h\>\
 \#include \<atfs.h\>

int af\_crkey (char \*syspath, char \*name, char \*type, Af\_key \*aso)

FILE \*af\_open (Af\_key \*aso, char \*mode)

int af\_close (FILE \*stream)

int af\_rm (Af\_key \*aso)

int af\_establish (Af\_key \*aso, char \*filename)

int af\_restore (Af\_key \*aso, Af\_key \*restoredAso)

## DESCRIPTION

*af\_crkey* creates an object key for a regular UNIX file identified by name, type and system path. *syspath* is an either absolute or relative directory name. An empty syspath refers to the current directory. By convention, AtFS interprets the filename suffix of a UNIX file as *type* and the filename without suffix as *name* attribute. To give an example, the path name

```
/usr/andy/foo.c is split up in /usr/andy (syspath) foo (name) c (type)
```

A period as first character in the filename is always considered as part of the name. Hence **.cshrc** has a name but no type. "." and ".." are recognized as names too. If the named UNIX file does not exist, af\_crkey creates an empty file. The created key remains accessible until it is explicitly given up by af\_dropkey (manual page [af\_retrieve(3)](/af_retrieve/3.md)).

*af\_open* opens the contents of the ASO pointed to by *aso* and associates a stream with it. A pointer to the FILE structure associated with the stream is returned. *Mode* is a character string that is either "r\[+\]", "w\[+\]" or "a\[+\]". See [fopen(3)](/fopen/3.md) for further details. Upon error, af\_open returns a NULL pointer. Non-busy ASOs can only be opened with mode "r". If a non-busy ASO is opened, it's contents will be placed in a temporary UNIX file due to storage of versions as deltas.

*af\_close* closes a stream previously opened by af\_open (see [fclose(3)](/fclose/3.md)). Temporary files created by af\_open, holding the contents of a saved versions are unlinked right after being opened so that they will automatically disappear on closing.

*af\_rm* removes the specified ASO. The application has to have a lock (see [af\_lock(3)](/af_lock/3.md)) set on the ASO that shall be deleted by af\_rm. ASOs with the state attribute set to **accessed** or **frozen** cannot be removed. If you keep multiple keys of one object (perhaps in different sets) af\_rm invalidates all keys of the removed object. As AtFS does not support multiple links to saved ASOs, af\_rm on a saved version always does a physical removal.

*af\_establish* establishes the contents of the saved version, pointed to by *aso* in a file named *filename*. The resulting file gets the version's modification and access date.

*af\_restore* is used to restore formerly saved derived ASOs into their old file location. It also restores the file modification and access date. This function cannot be applied to source objects. af\_restore returns the key of the restored version in the buffer *restoredAso*.

## SEE ALSO

[fopen(3)](/fopen/3.md), [fclose(3)](/fclose/3.md), [af\_retrieve(3)](/af_retrieve/3.md), [af\_lock(3)](/af_lock/3.md)

## DIAGNOSTICS

Upon error, -1 or a nil pointer (depending on the return type) is returned and *af\_errno* is set to the corresponding error number.
