RFS

tmpfile()

PROTOTYPE

#include <stdio.h>

FILE *tmpfile(void);

DESCRIPTION

tmpfile() creates a temporary file, opened with “wb+” mode, that is automatically removed when either the file is closed or the program terminates. Use of tmpfile() requires the “config.h” definition INC_RFS be set to TRUE, to include the TargetRFS RAM file system.

If successful, tmpfile() returns a file handle. Otherwise, it sets errno and returns NULL.

ERROR CODES

EINVAL The TargetRFS file system is not mounted.
EMFILE No file control block is free. FOPEN_MAX files are currently open.
ENOMEM Unable to allocate memory for file entry.

EXAMPLE

FILE *file;

/*-----------------------------------------------------------------*/
/* Open a temporary file to store the info in.                     */
/*-----------------------------------------------------------------*/
file = tmpfile();
if (file == NULL)
{
  perror("tmpfile() failed");
  return -1;
}