bfsDiscard()

PROTOTYPE

#include <bfs.h>

void bfsDiscard(void);

DESCRIPTION

bfsDiscard() closes a file open in write mode when it is no longer desired to create the file, most likely because of an error. After bfsDiscard() returns, the previously opened file will not exist. No metadata is written by bfsDiscard(), but TargetBFS resources are freed so that another open call can follow.

EXAMPLE

  /*-------------------------------------------------------------------*/
  /* Write data to file. If wrote all, close (saving file) and return. */
  /*-------------------------------------------------------------------*/
  rc = bfsWrite((void *)TMP_BUF_BEG, len);
  if (rc == len)
  {
    bfsClose();
    printf("Wrote %d bytes to \"bfs/%s\"\n", len, name);
    return;
  }

  /*-------------------------------------------------------------------*/
  /* Discard data and report reason for not saving file.               */
  /*-------------------------------------------------------------------*/
  bfsDiscard();
  if (rc > 0)
    puts("Not enough room to write entire file");
  else
    perror("bfsWrite()");