1CANONICALIZE_FILE_NAME(3)  Linux Programmer's Manual CANONICALIZE_FILE_NAME(3)
2
3
4

NAME

6       canonicalize_file_name - return the canonicalized absolute pathname
7

SYNOPSIS

9       #define _GNU_SOURCE         /* See feature_test_macros(7) */
10       #include <stdlib.h>
11
12       char *canonicalize_file_name(const char *path);
13

DESCRIPTION

15       The  canonicalize_file_name() function returns a null-terminated string
16       containing the canonicalized absolute pathname corresponding  to  path.
17       In  the  returned string, symbolic links are resolved, as are .  and ..
18       pathname components.  Consecutive slash (/) characters are replaced  by
19       a single slash.
20
21       The   returned   string   is   dynamically   allocated   by  canonical‐
22       ize_file_name() and the caller should deallocate it with  free(3)  when
23       it is no longer required.
24
25       The call canonicalize_file_name(path) is equivalent to the call:
26
27           realpath(path, NULL);
28

RETURN VALUE

30       On  success, canonicalize_file_name() returns a null-terminated string.
31       On error (e.g., a pathname component is unreadable or does not  exist),
32       canonicalize_file_name()  returns  NULL  and sets errno to indicate the
33       error.
34

ERRORS

36       See realpath(3).
37

ATTRIBUTES

39       For  an  explanation  of  the  terms  used   in   this   section,   see
40       attributes(7).
41
42       ┌─────────────────────────┬───────────────┬─────────┐
43Interface                Attribute     Value   
44       ├─────────────────────────┼───────────────┼─────────┤
45canonicalize_file_name() │ Thread safety │ MT-Safe │
46       └─────────────────────────┴───────────────┴─────────┘

CONFORMING TO

48       This function is a GNU extension.
49

SEE ALSO

51       readlink(2), realpath(3)
52

COLOPHON

54       This  page  is  part of release 4.16 of the Linux man-pages project.  A
55       description of the project, information about reporting bugs,  and  the
56       latest     version     of     this    page,    can    be    found    at
57       https://www.kernel.org/doc/man-pages/.
58
59
60
61GNU                               2017-09-15         CANONICALIZE_FILE_NAME(3)
Impressum