#include <limits.h> #include <stdlib.h> char *realpath(const char *path, char *resolved_path);Feature Test Macro Requirements for glibc (see feature_test_macros (7)):
-
realpath():
- _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
Description
realpath() expands all symbolic links and resolves references to /./, /../ and extra '/' characters in the null-terminated string named by path to produce a canonicalized absolute pathname. The resulting pathname is stored as a null-terminated string, up to a maximum of PATH_MAX bytes, in the buffer pointed to by resolved_path. The resulting path will have no symbolic link, /./ or /../ components.
If resolved_path is specified as NULL, then realpath() uses malloc(3) to allocate a buffer of up to PATH_MAX bytes to hold the resolved pathname, and returns a pointer to this buffer. The caller should deallocate this buffer using free(3).
Return Value
If there is no error, realpath() returns a pointer to the resolved_path.
Otherwise, it returns a NULL pointer, the contents of the array resolved_path are undefined, and errno is set to indicate the error
本文介绍了realpath函数的功能和使用方法,该函数用于将路径名规范化并解析符号链接,生成绝对路径。文章详细解释了参数含义及返回值,并指出在特定情况下如何分配和释放内存。
2746

被折叠的 条评论
为什么被折叠?



