📄 mkstemp.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>mkstemp</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_007_651"> </a>NAME</h4><blockquote>mkstemp - make a unique file name</blockquote><h4><a name = "tag_000_007_652"> </a>SYNOPSIS</h4><blockquote><pre><code>#include <<a href="stdlib.h.html">stdlib.h</a>>int mkstemp(char *<i>template</i>);</code></pre></blockquote><h4><a name = "tag_000_007_653"> </a>DESCRIPTION</h4><blockquote>The<i>mkstemp()</i>function replaces the contents of the string pointed to by<i>template</i>by a unique file name, and returns a file descriptor for the file open forreading and writing. The function thus prevents any possible race conditionbetween testing whether the file exists and opening it for use. The string in<i>template</i>should look like a file name with six trailing 'X's;<i>mkstemp()</i>replaces each 'X' with a character from the portable file name character set.The characters are chosen such that the resulting name does not duplicate thename of an existing file.</blockquote><h4><a name = "tag_000_007_654"> </a>RETURN VALUE</h4><blockquote>Upon successful completion,<i>mkstemp()</i>returns an open file descriptor. Otherwise -1 is returned if no suitablefile could be created.</blockquote><h4><a name = "tag_000_007_655"> </a>ERRORS</h4><blockquote>No errors are defined.</blockquote><h4><a name = "tag_000_007_656"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_657"> </a>APPLICATION USAGE</h4><blockquote>It is possible to run out of letters.<p>The<i>mkstemp()</i>function need not check to determine whether the file name part of<i>template</i>exceeds the maximum allowable file name length.<p>For portability with previous versions of this document,<i><a href="tmpfile.html">tmpfile()</a></i>is preferred over this function.</blockquote><h4><a name = "tag_000_007_658"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_659"> </a>SEE ALSO</h4><blockquote><i><a href="getpid.html">getpid()</a></i>,<i><a href="open.html">open()</a></i>,<i><a href="tmpfile.html">tmpfile()</a></i>,<i><a href="tmpnam.html">tmpnam()</a></i>,<i><a href="stdlib.h.html"><stdlib.h></a></i>.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -