delorie.com/djgpp/doc/libc/libc_839.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

unlink

Syntax

 
#include <unistd.h>

int unlink(const char *file);

Description

This function removes a file from the file system.

Return Value

Zero on success, nonzero on failure.

Portability

ANSI/ISO C No
POSIX 1003.2-1992 (partial); 1003.1-2001 (partial) (see note 1)

Notes:

  1. The POSIX specification requires this removal to be delayed until the file is no longer open. Due to problems with the underlying operating systems, this implementation of unlink does not fully comply with the specs; if the file you want to unlink is open, you're asking for trouble -- how much trouble depends on the underlying OS. On Windows NT (and possibly on Windows 2000 as well), you get the behaviour POSIX expects. On Windows 9x and Windows ME (and possibly Windows XP as well), the removal will simply fail (errno gets set to EACCES). On DOS, removing an open file could lead to filesystem corruption if the removed file is written to before it's closed.

Example

 
unlink("data.txt");

  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004