1canonicalize_file_name(3) Library Functions Manual canonicalize_file_name(3)
2
3
4
6 canonicalize_file_name - return the canonicalized absolute pathname
7
9 Standard C library (libc, -lc)
10
12 #define _GNU_SOURCE /* See feature_test_macros(7) */
13 #include <stdlib.h>
14
15 char *canonicalize_file_name(const char *path);
16
18 The canonicalize_file_name() function returns a null-terminated string
19 containing the canonicalized absolute pathname corresponding to path.
20 In the returned string, symbolic links are resolved, as are . and ..
21 pathname components. Consecutive slash (/) characters are replaced by
22 a single slash.
23
24 The returned string is dynamically allocated by canonical‐
25 ize_file_name() and the caller should deallocate it with free(3) when
26 it is no longer required.
27
28 The call canonicalize_file_name(path) is equivalent to the call:
29
30 realpath(path, NULL);
31
33 On success, canonicalize_file_name() returns a null-terminated string.
34 On error (e.g., a pathname component is unreadable or does not exist),
35 canonicalize_file_name() returns NULL and sets errno to indicate the
36 error.
37
39 See realpath(3).
40
42 For an explanation of the terms used in this section, see at‐
43 tributes(7).
44
45 ┌────────────────────────────────────────────┬───────────────┬─────────┐
46 │Interface │ Attribute │ Value │
47 ├────────────────────────────────────────────┼───────────────┼─────────┤
48 │canonicalize_file_name() │ Thread safety │ MT-Safe │
49 └────────────────────────────────────────────┴───────────────┴─────────┘
50
52 GNU.
53
55 readlink(2), realpath(3)
56
57
58
59Linux man-pages 6.04 2023-03-30 canonicalize_file_name(3)