This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. |
Remove a link to a file
#include <unistd.h> int unlink( const char * path );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The unlink() function removes a link to a file:
If the link count of the file becomes zero, and no process has the file open, then the space that the file occupies is freed, and no one can access the file anymore.
If one or more processes have the file open when the last link is removed, the link is removed, but the removal of the file is delayed until all references to it have been closed.
To remove a directory, call rmdir() or remove(). |
#include <unistd.h> #include <stdlib.h> int main( void ) { if( unlink( "vm.tmp" ) ) { puts( "Error removing vm.tmp!" ); return EXIT_FAILURE; } return EXIT_SUCCESS; }
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
chdir(), chmod(), close(), errno, getcwd(), link(), mkdir(), open(), pathmgr_symlink(), pathmgr_unlink(), remove(), rename(), rmdir(), stat(), symlink()