Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C |
both |
#include <stdio.h>
int remove(const char *filename);
Deletes the file specified by filename, unless the file is open. The remove() function removes memory files and DASD data sets. (Non-DASD data sets, such as tapes, are not supported.) It also removes individual members of PDSs and PDSEs, and even removes memory files that simulate PDSs.
The interpretation of the file name passed to remove() depends on whether POSIX(ON) is specified. For full details about filename considerations, see the topics about opening files in z/OS XL C/C++ Programming Guide.
Memory files must exist and they must be closed. However, if you have z/OS® UNIX C application running POSIX(ON), memory files don't need to be closed when removing an HFS memory file. The z/OS UNIX services rules of interoperability apply. See the topics about opening files in z/OS XL C/C++ Programming Guide, for specifying file names for MVS™ data sets and HFS files.
Special behavior for XPG4: If filename does not name a directory, remove(filename) is equivalent to unlink(filename). If filename names a directory, remove(filename) is equivalent to rmdir(filename).
If successful, remove() returns 0.
If unsuccessful, remove() returns nonzero to indicate an error.
⁄* CELEBR12
When you invoke this example with a file name, the program attempts to
remove that file.
It 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" );
}