194 lines
5.9 KiB
HTML
194 lines
5.9 KiB
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 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-2001<br>
|
|
Copyright © 2001 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 <<a href="../basedefs/stdlib.h.html">stdlib.h</a>><br>
|
|
<br>
|
|
char *realpath(const char *restrict</tt> <i>file_name</i><tt>,<br>
|
|
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 names
|
|
the same file, whose resolution does not involve <tt>'.'</tt> , <tt>'..'</tt> , or symbolic links. The generated pathname shall be
|
|
stored as a null-terminated string, up to a maximum of {PATH_MAX} bytes, in the buffer pointed to by <i>resolved_name</i>.</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>() shall
|
|
return 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>Either the <i>file_name</i> or <i>resolved_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 generated
|
|
pathname is stored in the <i>actualpath</i> array.</p>
|
|
|
|
<pre>
|
|
<tt>#include <stdlib.h>
|
|
...
|
|
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>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_599_09"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</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 of
|
|
IEEE Std 1003.1-2001, <a href="../basedefs/stdlib.h.html"><i><stdlib.h></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 9899:1999
|
|
standard.</p>
|
|
|
|
<p>The wording of the mandatory [ELOOP] error condition is updated, and a second optional [ELOOP] error condition is added.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® 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>
|
|
|