basic.%unlink

C Function/BASIC Program, Releases: AP/Unix

Removes a directory entry.

Syntax

code=%unlink( path )

Description

removes the directory entry named by the path name pointed to by 'path'. The named file is unlinked, and when all the links have been removed, and the file is no longer open, the file is removed.

Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and system(0) is set to the value of errno.

Example

include dm,bp,unix.h fcntl.h

* Get a unique temporary file name
fn='/tmp':system(19)
fd=%creat( fn, O$RDWR )
...

* Remove the temporary file
if %unlink( fn ) # 0 then
crt 'Cannot remove temporary file. Error ':system(0)
end

See Also

Command Name Type Description
basic.cfunc Definition can be called from a Pick/BASIC program or subroutine in AP/DOS and AP/Unix implementations using a syntax similar to that of normal C.
basic.%close C Function Closes a Unix file.
basic.%creat C Function Creates new Unix file, or rewrites to existing file.
basic.%open C Function Opens a Unix file for reading or writing.

User Comments

What do you think?

Share your experience or ask a question by using the form below.

Login to leave your comments.