version 1 showing authors affecting page license.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
DIRNAME |
|
|
2 |
!!!DIRNAME |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
EXAMPLE |
|
|
7 |
RETURN VALUE |
|
|
8 |
BUGS |
|
|
9 |
CONFORMING TO |
|
|
10 |
SEE ALSO |
|
|
11 |
---- |
|
|
12 |
!!NAME |
|
|
13 |
|
|
|
14 |
|
|
|
15 |
dirname, basename - Parse pathname components |
|
|
16 |
!!SYNOPSIS |
|
|
17 |
|
|
|
18 |
|
|
|
19 |
__#include |
|
|
20 |
__ ''*path''__); |
|
|
21 |
char *basename(char__ ''*path''__); |
|
|
22 |
__ |
|
|
23 |
!!DESCRIPTION |
|
|
24 |
|
|
|
25 |
|
|
|
26 |
__dirname__ and __basename__ break a null-terminated |
|
|
27 |
pathname string into directory and filename components. In |
|
|
28 |
the usual case, __dirname__ returns the string up to, but |
|
|
29 |
not including, the final '/', and __basename__ returns |
|
|
30 |
the component following the final '/'. Trailing '/' |
|
|
31 |
characters are not counted as part of the |
|
|
32 |
pathname. |
|
|
33 |
|
|
|
34 |
|
|
|
35 |
If ''path'' does not contain a slash, __dirname__ |
|
|
36 |
returns the string __basename__ |
|
|
37 |
returns a copy of ''path''. If ''path'' is the string |
|
|
38 |
''dirname__ and __basename__ |
|
|
39 |
return the string __path'' is a NULL |
|
|
40 |
pointer or points to an empty string, then both |
|
|
41 |
__dirname__ and __basename__ return the string |
|
|
42 |
__ |
|
|
43 |
|
|
|
44 |
|
|
|
45 |
Concatenating the string returned by __dirname__, a |
|
|
46 |
__basename__ |
|
|
47 |
yields a complete pathname. |
|
|
48 |
|
|
|
49 |
|
|
|
50 |
Both __dirname__ and __basename__ may modify the |
|
|
51 |
contents of ''path'', so if you need to preserve the |
|
|
52 |
pathname string, copies should be passed to these functions. |
|
|
53 |
Furthermore, __dirname__ and __basename__ may return |
|
|
54 |
pointers to statically allocated memory which may |
|
|
55 |
overwritten by subsequent calls. |
|
|
56 |
|
|
|
57 |
|
|
|
58 |
The following list of examples (taken from SUSv2) shows the |
|
|
59 |
strings returned by __dirname__ and __basename__ for |
|
|
60 |
different paths: |
|
|
61 |
|
|
|
62 |
|
|
|
63 |
__path dirname basename |
|
|
64 |
__ |
|
|
65 |
__ |
|
|
66 |
!!EXAMPLE |
|
|
67 |
|
|
|
68 |
|
|
|
69 |
char *dirc, *basec, *bname, *dname; |
|
|
70 |
char *path = |
|
|
71 |
!!RETURN VALUE |
|
|
72 |
|
|
|
73 |
|
|
|
74 |
Both __dirname__ and __basename__ return pointers to |
|
|
75 |
null-terminated strings. |
|
|
76 |
!!BUGS |
|
|
77 |
|
|
|
78 |
|
|
|
79 |
In versions of glibc up to and including 2.2.1, |
|
|
80 |
__dirname__ does not correctly handle pathnames with |
|
|
81 |
trailing '/' characters, and generates a segmentation |
|
|
82 |
violation if given a NULL argument. |
|
|
83 |
!!CONFORMING TO |
|
|
84 |
|
|
|
85 |
|
|
|
86 |
SUSv2 |
|
|
87 |
!!SEE ALSO |
|
|
88 |
|
|
|
89 |
|
|
|
90 |
dirname(1), basename(1), |
|
|
91 |
---- |