中间件,开发工具,实时操作系统软件和支持服务,助您完成卓越的嵌入式设计
Home
Developer Resources
Developer Support

QNX Developer Support

PDF Documents
More resources
[Previous] [Contents] [Index] [Next]

remove()

Remove a link to a file

Synopsis:

#include <stdio.h>

int remove( const char * filename );

Arguments:

filename
The path to the file that you want to delete.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The remove() function removes a link to a file:

The remove() function also works on directories; however, rmdir() is more efficient.

Returns:

0
The operation was successful.
Nonzero
The operation failed (errno is set).

Errors:

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.

Examples:

#include <stdio.h>
#include <stdlib.h>

int main( void )
{
    if( remove( "vm.tmp" ) ) {
        puts( "Error removing vm.tmp!" );
        return EXIT_FAILURE;
    }

    return EXIT_SUCCESS;
}

Classification:

ANSI, POSIX 1003.1

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler No
Thread Yes

See also:

errno, rmdir(), unlink()


[Previous] [Contents] [Index] [Next]
 
©2013 QNX Software Systems Limited, a subsidiary of BlackBerry.   BlackBerry Logo