⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 realpath.html

📁 IEEE 1003.1-2003, Single Unix Specification v3
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>realpath</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="realpath"></a> <a name="tag_03_599"></a><!-- realpath --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright &copy; 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_599_01"></a>NAME</h4><blockquote>realpath - resolve a pathname</blockquote><h4><a name="tag_03_599_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><div class="box"><code><tt><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> #include &lt;<a href="../basedefs/stdlib.h.html">stdlib.h</a>&gt;<br><br> char *realpath(const char *restrict</tt> <i>file_name</i><tt>,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char *restrict</tt> <i>resolved_name</i><tt>); <img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div><tt><br></tt></blockquote><h4><a name="tag_03_599_03"></a>DESCRIPTION</h4><blockquote><p>The <i>realpath</i>() function shall derive, from the pathname pointed to by <i>file_name</i>, an absolute pathname that namesthe same file, whose resolution does not involve <tt>'.'</tt> , <tt>'..'</tt> , or symbolic links. The generated pathname shall bestored as a null-terminated string, up to a maximum of {PATH_MAX} bytes, in the buffer pointed to by <i>resolved_name</i>.</p><p>If <i>resolved_name</i> is a null pointer, the behavior of <i>realpath</i>() is implementation-defined.</p></blockquote><h4><a name="tag_03_599_04"></a>RETURN VALUE</h4><blockquote><p>Upon successful completion, <i>realpath</i>() shall return a pointer to the resolved name. Otherwise, <i>realpath</i>() shallreturn a null pointer and set <i>errno</i> to indicate the error, and the contents of the buffer pointed to by <i>resolved_name</i>are undefined.</p></blockquote><h4><a name="tag_03_599_05"></a>ERRORS</h4><blockquote><p>The <i>realpath</i>() function shall fail if:</p><dl compact><dt>[EACCES]</dt><dd>Read or search permission was denied for a component of <i>file_name</i>.</dd><dt>[EINVAL]</dt><dd>The <i>file_name</i> argument is a null pointer.</dd><dt>[EIO]</dt><dd>An error occurred while reading from the file system.</dd><dt>[ELOOP]</dt><dd>A loop exists in symbolic links encountered during resolution of the <i>path</i> argument.</dd><dt>[ENAMETOOLONG]</dt><dd>The length of the <i>file_name</i> argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}.</dd><dt>[ENOENT]</dt><dd>A component of <i>file_name</i> does not name an existing file or <i>file_name</i> points to an empty string.</dd><dt>[ENOTDIR]</dt><dd>A component of the path prefix is not a directory.</dd></dl><p>The <i>realpath</i>() function may fail if:</p><dl compact><dt>[ELOOP]</dt><dd>More than {SYMLOOP_MAX} symbolic links were encountered during resolution of the <i>path</i> argument.</dd><dt>[ENAMETOOLONG]</dt><dd>Pathname resolution of a symbolic link produced an intermediate result whose length exceeds {PATH_MAX}.</dd><dt>[ENOMEM]</dt><dd>Insufficient storage space is available.</dd></dl></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_599_06"></a>EXAMPLES</h4><blockquote><h5><a name="tag_03_599_06_01"></a>Generating an Absolute Pathname</h5><p>The following example generates an absolute pathname for the file identified by the <i>symlinkpath</i> argument. The generatedpathname is stored in the <i>actualpath</i> array.</p><pre><tt>#include &lt;stdlib.h&gt;...char *symlinkpath = "/tmp/symlink/file";char actualpath [PATH_MAX+1];char *ptr;<br>ptr = realpath(symlinkpath, actualpath);</tt></pre></blockquote><h4><a name="tag_03_599_07"></a>APPLICATION USAGE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_599_08"></a>RATIONALE</h4><blockquote><p>Since the maximum pathname length is arbitrary unless {PATH_MAX} is defined, an application generally cannot supply a<i>resolved_name</i> buffer with size {{PATH_MAX}+1}.</p></blockquote><h4><a name="tag_03_599_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>In the future, passing a null pointer to <i>realpath</i>() for the <i>resolved_name</i> argument may be defined to have<i>realpath</i>() allocate space for the generated pathname.</p></blockquote><h4><a name="tag_03_599_10"></a>SEE ALSO</h4><blockquote><p><a href="getcwd.html"><i>getcwd</i>()</a> , <a href="sysconf.html"><i>sysconf</i>()</a> , the Base Definitions volume ofIEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/stdlib.h.html"><i>&lt;stdlib.h&gt;</i></a></p></blockquote><h4><a name="tag_03_599_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 4, Version 2.</p></blockquote><h4><a name="tag_03_599_12"></a>Issue 5</h4><blockquote><p>Moved from X/OPEN UNIX extension to BASE.</p></blockquote><h4><a name="tag_03_599_13"></a>Issue 6</h4><blockquote><p>The <b>restrict</b> keyword is added to the <i>realpath</i>() prototype for alignment with the ISO/IEC&nbsp;9899:1999standard.</p><p>The wording of the mandatory [ELOOP] error condition is updated, and a second optional [ELOOP] error condition is added.</p><p>IEEE&nbsp;Std 1003.1-2001/Cor&nbsp;1-2002, item XSH/TC1/D6/51 is applied, adding new text to the DESCRIPTION for the case when<i>resolved_name</i> is a null pointer, changing the [EINVAL] error text, adding text to the RATIONALE, and adding text to FUTUREDIRECTIONS.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX &reg; is a registered Trademark of The Open Group.<br>POSIX &reg; is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -