gtpc2m5uC/C++ Language Support User's Guide

remove-Delete a File

This function deletes a link to a file.

Format

#include <stdio.h>
int remove(const char *filename);

filename
The path name of the link to be deleted.

Normal Return

If successful, the remove function returns a 0 value.

Error Return

If not successful, the remove function returns a nonzero value.

Programming Considerations

 The TPF system does not support creating, updating, or deleting files in 1052 or UTIL state. Special files may or may not be writable in 1052 or UTIL state depending on the device driver implementation. 

Examples

In the following example, the remove function is called with a file name. The program issues a message if an error occurs.

#include <stdio.h>
 
int main(int argc, char ** argv)
{
  if ( argc != 2 )
    printf( "Usage: %s fn\n", argv[0] );
  else
    if ( remove( argv[1] ) != 0 )
      printf( "Could not remove file\n" );
}

Related Information

See Appendix E, Programming Support for the TPF File System for more information about TPF File System C Functions.