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

📄 chdir.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>chdir</title></head><body bgcolor="white"><basefont size="3"> <a name="chdir"></a> <a name="tag_03_69"></a><!-- chdir --> <!--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_69_01"></a>NAME</h4><blockquote>chdir - change working directory</blockquote><h4><a name="tag_03_69_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>#include &lt;<a href="../basedefs/unistd.h.html">unistd.h</a>&gt;<br><br> int chdir(const char *</tt><i>path</i><tt>);<br></tt></code></p></blockquote><h4><a name="tag_03_69_03"></a>DESCRIPTION</h4><blockquote><p>The <i>chdir</i>() function shall cause the directory named by the pathname pointed to by the <i>path</i> argument to become thecurrent working directory; that is, the starting point for path searches for pathnames not beginning with <tt>'/'</tt> .</p></blockquote><h4><a name="tag_03_69_04"></a>RETURN VALUE</h4><blockquote><p>Upon successful completion, 0 shall be returned. Otherwise, -1 shall be returned, the current working directory shall remainunchanged, and <i>errno</i> shall be set to indicate the error.</p></blockquote><h4><a name="tag_03_69_05"></a>ERRORS</h4><blockquote><p>The <i>chdir</i>() function shall fail if:</p><dl compact><dt>[EACCES]</dt><dd>Search permission is denied for any component of the pathname.</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>path</i> argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}.</dd><dt>[ENOENT]</dt><dd>A component of <i>path</i> does not name an existing directory or <i>path</i> is an empty string.</dd><dt>[ENOTDIR]</dt><dd>A component of the pathname is not a directory.</dd></dl><p>The <i>chdir</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>As a result of encountering a symbolic link in resolution of the <i>path</i> argument, the length of the substituted pathnamestring exceeded {PATH_MAX}.</dd></dl></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_69_06"></a>EXAMPLES</h4><blockquote><h5><a name="tag_03_69_06_01"></a>Changing the Current Working Directory</h5><p>The following example makes the value pointed to by <b>directory</b>, <b>/tmp</b>, the current working directory.</p><pre><tt>#include &lt;unistd.h&gt;...char *directory = "/tmp";int ret;<br>ret = chdir (directory);</tt></pre></blockquote><h4><a name="tag_03_69_07"></a>APPLICATION USAGE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_69_08"></a>RATIONALE</h4><blockquote><p>The <i>chdir</i>() function only affects the working directory of the current process.</p></blockquote><h4><a name="tag_03_69_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_69_10"></a>SEE ALSO</h4><blockquote><p><a href="getcwd.html"><i>getcwd</i>()</a> , the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/unistd.h.html"><i>&lt;unistd.h&gt;</i></a></p></blockquote><h4><a name="tag_03_69_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 1. Derived from Issue 1 of the SVID.</p></blockquote><h4><a name="tag_03_69_12"></a>Issue 6</h4><blockquote><p>The APPLICATION USAGE section is added.</p><p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p><ul><li><p>The [ELOOP] mandatory error condition is added.</p></li><li><p>A second [ENAMETOOLONG] is added as an optional error condition.</p></li></ul><p>The following changes were made to align with the IEEE&nbsp;P1003.1a draft standard:</p><ul><li><p>The [ELOOP] optional error condition is added.</p></li></ul></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 + -