|
|
1.1 root 1:
2:
3: unlink() COHERENT System Call unlink()
4:
5:
6:
7:
8: Remove a file
9:
10: iinntt uunnlliinnkk(_n_a_m_e) cchhaarr *_n_a_m_e;
11:
12: unlink removes the directory entry for the given file name, which
13: in effect erases name from the disk. name cannot be opened once
14: it has been unlinked. If name is the last link, unlink frees the
15: i-node and data blocks. Deallocation is delayed if the file is
16: open. Other links to the file remain intact.
17:
18: ***** Example *****
19:
20: This example removes the files named on the command line.
21:
22:
23: main(argc, argv)
24: int argc; char *argv[];
25: {
26: int i;
27:
28:
29:
30: for (i = 1; i < argc; i++) {
31: if (unlink(argv[i]) == -1) {
32: printf("Cannot unlink \"%s\"\n", argv[i]);
33: exit(1);
34: }
35: }
36: exit(0);
37: }
38:
39:
40: ***** See Also *****
41:
42: COHERENT system calls, link(), ln, rm, rmdir
43:
44: ***** Diagnostics *****
45:
46: uunnlliinnkk returns zero when successful. It returns -1 if file does
47: not exist, if the user does not have write and search permission
48: in the directory containing file, or if file is a directory and
49: the invoker is not the superuser.
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64: COHERENT Lexicon Page 1
65:
66:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.