Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edited by NavBot (jp)

...

Wiki Markup
This compliant solution uses the POSIX {{unlink()}} function to remove the file.  The {{unlink()}} function  is guaranteed  to unlink the file from the file system hierarchy but keep the file on disk until all open instances of the file are closed \[[Open Group 04|AA. References#OpenBibliography#Open Group 04]\].

Code Block
bgColor#ccccff
FILE *file;
char *file_name;

/* initialize file_name */

file = fopen(file_name, "w+");
if (file == NULL) {
  /* Handle error condition */
}

if (unlink(file_name) != 0) {
  /* Handle error condition */
}

/*... continue performing I/O operations on file ...*/

fclose(file);

...

Wiki Markup
\[[ISO/IEC 9899:1999|AA. References#ISOBibliography#ISO/IEC 9899-1999]\] Section 7.19.4.1, "The {{remove}} function"
\[[Open Group 04|AA. References#OpenBibliography#Open Group 04]\] [{{unlink()}}|http://www.opengroup.org/onlinepubs/000095399/functions/unlink.html]

...