lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

D Burgess wrote:
> I understand, someone correct me if I am wrong that on
> Unix unlink will remove the file when the last user of it
> closes the file.

The name is removed immediately but the contents of the
file may stay and is removed only when the last user closes
the file.

The difference between unlink and remove is, that unlink won't
delete directories.  remove does as long as the directory is
empty.  On older system which lack remove you had to call rmdir
the delete directories.

> THis equals the FILEFLAG_DELETE_ON_CLOSE on windows.

Sure?  Will this example work?  It will give you ten
/different/ files:

    int fd[10];
    for (int i = 0; i < 10; i++) {
       fd[i] = open("foo", O_CREAT|O_TRUNC|O_RDWR, 0666);

> On windows remove and unlink require exclusive access.

Posix allows this restriction (errno=EBUSY) but it's unusual
and most Unixes let you delete busy files/directories. 

Ciao, ET.