Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/r/remove.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/r/remove.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/r/remove.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/r/remove.html on line 8
Remove a link to a file
#include <stdio.h>
int remove( const char * filename );
- filename
- The path to the file that you want to delete.
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
The remove() function removes a link to a file:
- If the filename names a symbolic link, remove()
removes the link, but doesn't affect the file or directory that the
link goes to.
- If the filename isn't a symbolic link, remove()
removes the link and decrements the link count of the file that the
link refers to.
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.
The remove() function also
works on directories; however, rmdir() is more efficient.
- 0
- The operation was successful.
- Nonzero
- The operation failed (errno is set).
- EACCES
- Search permission is denied for a component of filename,
or write permission is denied on the directory containing the link to be removed.
- EBUSY
- The directory named by filename can't be unlinked
because it's being used by the system or another process,
and the target filesystem or resource manager considers this to be an error.
- ENAMETOOLONG
- The filename argument exceeds PATH_MAX in length,
or a pathname component is longer than NAME_MAX.
- ENOENT
- The named file doesn't exist, or filename is an empty string.
- ENOSYS
- The remove() function isn't implemented for the filesystem specified by filename.
- ENOTDIR
- A component of filename isn't a directory.
- EPERM
- The file named by filename is a directory,
and either the calling process doesn't have the appropriate privileges,
or the target filesystem or resource manager prohibits using remove() on directories.
- EROFS
- The directory entry to be unlinked resides on a read-only filesystem.
#include <stdio.h>
#include <stdlib.h>
int main( void )
{
if( remove( "vm.tmp" ) ) {
puts( "Error removing vm.tmp!" );
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
ANSI,
POSIX 1003.1
Safety: | |
Cancellation point |
Yes |
Interrupt handler |
No |
Signal handler |
No |
Thread |
Yes |
errno,
rmdir(),
unlink()
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/r/remove.html on line 214
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/r/remove.html on line 214