NAME

cat_getfile - read a file into memory.

SYNOPSIS

#include <cat/catutil.h>

int cat_getfile(const char *path, char **ptr);

DESCRIPTION

Reads file path into memory. The memory is allocated and returned in the ptr argument. The data is terminated with an extra NUL byte. The memory needs to be freed by the caller with a call to free().

RETURN VALUES

Returns the length of the data not including the NUL byte, or a negative code on error.

If path refers to anything other than an ordinary file, the function returns CAT_EFTYPE.

SEE ALSO

cat, catutil, cat_filelength, cat_filetime, cat_truncatefile, cat_lockfile, cat_lockfile, cat_unlockfile