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

📄 basename.html

📁 posix标准英文,html格式
💻 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-2004 IEEE and The Open Group, All Rights Reserved --><title>basename</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="basename"></a> <a name="tag_03_36"></a><!-- basename --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2004 Edition<br>Copyright &copy; 2001-2004 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_36_01"></a>NAME</h4><blockquote>basename - return the last component of a pathname</blockquote><h4><a name="tag_03_36_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/libgen.h.html">libgen.h</a>&gt;<br><br> char *basename(char *</tt><i>path</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_36_03"></a>DESCRIPTION</h4><blockquote><p>The <i>basename</i>() function shall take the pathname pointed to by <i>path</i> and return a pointer to the final component ofthe pathname, deleting any trailing <tt>'/'</tt> characters.</p><p>If the string pointed to by <i>path</i> consists entirely of the <tt>'/'</tt> character, <i>basename</i>() shall return apointer to the string <tt>"/"</tt>. If the string pointed to by <i>path</i> is exactly <tt>"//"</tt>, it isimplementation-defined whether <tt>'/'</tt> or <tt>"//"</tt> is returned.</p><p>If <i>path</i> is a null pointer or points to an empty string, <i>basename</i>() shall return a pointer to the string<tt>"."</tt>.</p><p>The <i>basename</i>() function may modify the string pointed to by <i>path</i>, and may return a pointer to static storage thatmay then be overwritten by a subsequent call to <i>basename</i>().</p><p>The <i>basename</i>() function need not be reentrant. A function that is not required to be reentrant is not required to bethread-safe.</p></blockquote><h4><a name="tag_03_36_04"></a>RETURN VALUE</h4><blockquote><p>The <i>basename</i>() function shall return a pointer to the final component of <i>path</i>.</p></blockquote><h4><a name="tag_03_36_05"></a>ERRORS</h4><blockquote><p>No errors are defined.</p></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_36_06"></a>EXAMPLES</h4><blockquote><h5><a name="tag_03_36_06_01"></a>Using basename()</h5><p>The following program fragment returns a pointer to the value <i>lib</i>, which is the base name of <b>/usr/lib</b>.</p><pre><tt>#include &lt;libgen.h&gt;...char *name = "/usr/lib";char *base;<br>base = basename(name);...</tt></pre><h5><a name="tag_03_36_06_02"></a>Sample Input and Output Strings for basename()</h5><p>In the following table, the input string is the value pointed to by <i>path</i>, and the output string is the return value ofthe <i>basename</i>() function.</p><center><table border="1" cellpadding="3" align="center"><tr valign="top"><th align="center"><p class="tent"><b>Input String</b></p></th><th align="center"><p class="tent"><b>Output String</b></p></th></tr><tr valign="top"><td align="left"><p class="tent">"/usr/lib"</p></td><td align="left"><p class="tent">"lib"</p></td></tr><tr valign="top"><td align="left"><p class="tent">"/usr/"</p></td><td align="left"><p class="tent">"usr"</p></td></tr><tr valign="top"><td align="left"><p class="tent">"/"</p></td><td align="left"><p class="tent">"/"</p></td></tr><tr valign="top"><td align="left"><p class="tent">"///"</p></td><td align="left"><p class="tent">"/"</p></td></tr><tr valign="top"><td align="left"><p class="tent">"//usr//lib//"</p></td><td align="left"><p class="tent">"lib"</p></td></tr></table></center></blockquote><h4><a name="tag_03_36_07"></a>APPLICATION USAGE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_36_08"></a>RATIONALE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_36_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_36_10"></a>SEE ALSO</h4><blockquote><p><a href="dirname.html"><i>dirname</i>()</a>, the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/libgen.h.html"><i>&lt;libgen.h&gt;</i></a>, the Shell and Utilities volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../utilities/basename.html"><i>basename</i></a></p></blockquote><h4><a name="tag_03_36_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 4, Version 2.</p></blockquote><h4><a name="tag_03_36_12"></a>Issue 5</h4><blockquote><p>Moved from X/OPEN UNIX extension to BASE.</p><p>Normative text previously in the APPLICATION USAGE section is moved to the DESCRIPTION.</p><p>A note indicating that this function need not be reentrant is added to the DESCRIPTION.</p></blockquote><h4><a name="tag_03_36_13"></a>Issue 6</h4><blockquote><p>In the DESCRIPTION, the note about reentrancy is expanded to cover thread-safety.</p><p>IEEE&nbsp;Std&nbsp;1003.1-2001/Cor&nbsp;2-2004, item XSH/TC2/D6/20 is applied, changing the DESCRIPTION to make it clear thatthe string referenced is the string pointed to by <i>path.</i></p></blockquote><div class="box"><em>End of informative text.</em></div><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 + -