system_unlink(3f) - [M_system:FILE_SYSTEM] remove a directory entry relative to directory file descriptor (LICENSE:PD)
Synopsis
Description
Return Value
Examples
elemental impure integer function unlink(path);
character(len=*) :: path
The unlink() function shall remove a link to a file. If path names a symbolic link, unlink() shall remove the symbolic link named by path and shall not affect any file or directory named by the contents of the symbolic link. Otherwise, unlink() shall remove the link named by the pathname pointed to by path and shall decrement the link count of the file referenced by the link.When the files link count becomes 0 and no process has the file open, the space occupied by the file shall be freed and the file shall no longer be accessible. If one or more processes have the file open when the last link is removed, the link shall be removed before unlink() returns, but the removal of the file contents shall be postponed until all references to the file are closed.
The path argument shall not name a directory unless the process has appropriate privileges and the implementation supports using unlink() on directories.
Upon successful completion, unlink() shall mark for update the last data modification and last file status change timestamps of the parent directory. Also, if the files link count is not 0, the last file status change timestamp of the file shall be marked for update.
Values for flag are constructed by a bitwise-inclusive OR of flags from the following list, defined in <fcntl.h>:
Remove the directory entry specified by fd and path as a directory, not a normal file.
Upon successful completion, these functions shall return 0. Otherwise, these functions shall return -1 and set errno to indicate the error. If -1 is returned, the named file shall not be changed.
Removing a link to a file
program demo_system_unlink use M_system, only : system_unlink, system_perror integer :: ierr ierr = system_unlink(myfile1) if(ierr.ne.0)then call system_perror(*demo_system_unlink*) endif end program demo_system_unlink
Nemo Release 3.1 | system_unlink (3m_system) | March 07, 2025 |