📄 iolib.html
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/ioLib.html - generated by refgen from ioLib.c --> <title> ioLib </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.html"><i>VxWorks Reference Manual : Libraries</i></a></p></blockquote><h1>ioLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>ioLib</strong> - I/O interface library </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><i><a href="./ioLib.html#creat">creat</a></i>( )</b> - create a file<br><b><i><a href="./ioLib.html#unlink">unlink</a></i>( )</b> - delete a file (POSIX)<br><b><i><a href="./ioLib.html#remove">remove</a></i>( )</b> - remove a file (ANSI)<br><b><i><a href="./ioLib.html#open">open</a></i>( )</b> - open a file<br><b><i><a href="./ioLib.html#close">close</a></i>( )</b> - close a file<br><b><i><a href="./ioLib.html#rename">rename</a></i>( )</b> - change the name of a file<br><b><i><a href="./ioLib.html#read">read</a></i>( )</b> - read bytes from a file or device<br><b><i><a href="./ioLib.html#write">write</a></i>( )</b> - write bytes to a file<br><b><i><a href="./ioLib.html#ioctl">ioctl</a></i>( )</b> - perform an I/O control function<br><b><i><a href="./ioLib.html#lseek">lseek</a></i>( )</b> - set a file read/write pointer<br><b><i><a href="./ioLib.html#ioDefPathSet">ioDefPathSet</a></i>( )</b> - set the current default path<br><b><i><a href="./ioLib.html#ioDefPathGet">ioDefPathGet</a></i>( )</b> - get the current default path<br><b><i><a href="./ioLib.html#chdir">chdir</a></i>( )</b> - set the current default path<br><b><i><a href="./ioLib.html#getcwd">getcwd</a></i>( )</b> - get the current default path (POSIX)<br><b><i><a href="./ioLib.html#getwd">getwd</a></i>( )</b> - get the current default path<br><b><i><a href="./ioLib.html#ioGlobalStdSet">ioGlobalStdSet</a></i>( )</b> - set the file descriptor for global standard input/output/error<br><b><i><a href="./ioLib.html#ioGlobalStdGet">ioGlobalStdGet</a></i>( )</b> - get the file descriptor for global standard input/output/error<br><b><i><a href="./ioLib.html#ioTaskStdSet">ioTaskStdSet</a></i>( )</b> - set the file descriptor for task standard input/output/error<br><b><i><a href="./ioLib.html#ioTaskStdGet">ioTaskStdGet</a></i>( )</b> - get the file descriptor for task standard input/output/error<br><b><i><a href="./ioLib.html#isatty">isatty</a></i>( )</b> - return whether the underlying driver is a tty device<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library contains the interface to the basic I/O system.It includes:<ul><li>Interfaces to the seven basic driver-provided functions:<b><i><a href="./ioLib.html#creat">creat</a></i>( )</b>, <b><i><a href="./ioLib.html#remove">remove</a></i>( )</b>, <b><i><a href="./ioLib.html#open">open</a></i>( )</b>, <b><i><a href="./ioLib.html#close">close</a></i>( )</b>, <b><i><a href="./ioLib.html#read">read</a></i>( )</b>, <b><i><a href="./ioLib.html#write">write</a></i>( )</b>, and <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>( )</b>.</li><li>Interfaces to several file system functions, including<b><i><a href="./ioLib.html#rename">rename</a></i>( )</b> and <b><i><a href="./ioLib.html#lseek">lseek</a></i>( )</b>.</li><li>Routines to set and get the current working directory.</li><li>Routines to assign task and global standard file descriptors.</ul><p></blockquote><h4>FILE DESCRIPTORS</h4><blockquote><p><p>At the basic I/O level, files are referred to by a file descriptor.A file descriptor is a small integer returned by a call to <b><i><a href="./ioLib.html#open">open</a></i>( )</b> or <b><i><a href="./ioLib.html#creat">creat</a></i>( )</b>. The other basic I/O calls take a file descriptor as a parameter to specify the intended file.<p>Three file descriptors are reserved and have special meanings:<p> 0 (<b>STD_IN</b>) - standard input<br> 1 (<b>STD_OUT</b>) - standard output<br> 2 (<b>STD_ERR</b>) - standard error output<p>VxWorks allows two levels of redirection. First, there is a globalassignment of the three standard file descriptors. By default, new tasks usethis global assignment. The global assignment of the three standardfile descriptors is controlled by the routines <b><i><a href="./ioLib.html#ioGlobalStdSet">ioGlobalStdSet</a></i>( )</b> and <b><i><a href="./ioLib.html#ioGlobalStdGet">ioGlobalStdGet</a></i>( )</b>.<p>Second, individual tasks may override the global assignment of thesefile descriptors with their own assignments that apply only to that task. The assignment of task-specific standard file descriptors is controlled by the routines <b><i><a href="./ioLib.html#ioTaskStdSet">ioTaskStdSet</a></i>( )</b> and <b><i><a href="./ioLib.html#ioTaskStdGet">ioTaskStdGet</a></i>( )</b>. <p></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>ioLib.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ioLib.html#top">ioLib</a></b>, <b><a href="./iosLib.html#top">iosLib</a></b>, ansiStdio, <i>VxWorks Programmer's Guide: I/O System</i><hr><a name="creat"></a><p align=right><a href="rtnIndex.html"><i>Libraries : Routines</i></a></p></blockquote><h1><i>creat</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>creat</i>( )</strong> - create a file</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int creat ( const char * name, /* name of the file to create */ int flag /* O_RDONLY, O_WRONLY, or O_RDWR */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine creates a file called <i>name</i> and opens it with a specified<i>flag</i>. This routine determines on which device to create the file; it then calls the create routine of the device driver to do most of the work.Therefore, much of what transpires is device/driver-dependent.<p>The parameter <i>flag</i> is set to <b>O_RDONLY</b> (0), <b>O_WRONLY</b> (1), or <b>O_RDWR</b> (2)for the duration of time the file is open. To create NFS files with aUNIX chmod-type file mode, call <b><i><a href="./ioLib.html#open">open</a></i>( )</b> with the file mode specified inthe third argument.<p></blockquote><h4>NOTE</h4><blockquote><p>For more information about situations when there are no file descriptorsavailable, see the manual entry for <b><i><a href="./iosLib.html#iosInit">iosInit</a></i>( )</b>.<p></blockquote><h4>RETURNS</h4><blockquote><p><p>A file descriptor number, or ERROR if a filename is not specified, thedevice does not exist, no file descriptors are available, or the driverreturns ERROR.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ioLib.html#top">ioLib</a></b>, <b><i><a href="./ioLib.html#open">open</a></i>( )</b><hr><a name="unlink"></a><p align=right><a href="rtnIndex.html"><i>Libraries : Routines</i></a></p></blockquote><h1><i>unlink</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>unlink</i>( )</strong> - delete a file (POSIX)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS unlink ( char * name /* name of the file to remove */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine deletes a specified file. It performs the same functionas <b><i><a href="./ioLib.html#remove">remove</a></i>( )</b> and is provided for POSIX compatibility.<p></blockquote><h4>RETURNS</h4><blockquote><p><p>OK if there is no delete routine for the device or the driver returns OK;ERROR if there is no such device or the driver returns ERROR.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ioLib.html#top">ioLib</a></b>, <b><i><a href="./ioLib.html#remove">remove</a></i>( )</b><hr><a name="remove"></a><p align=right><a href="rtnIndex.html"><i>Libraries : Routines</i></a></p></blockquote><h1><i>remove</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>remove</i>( )</strong> - remove a file (ANSI)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS remove ( const char * name /* name of the file to remove */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine deletes a specified file. It calls the driver for theparticular device on which the file is located to do the work.<p></blockquote><h4>RETURNS</h4><blockquote><p><p>OK if there is no delete routine for the device or the driver returns OK;ERROR if there is no such device or the driver returns ERROR.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ioLib.html#top">ioLib</a></b>, <i>American National Standard for Information Systems - </i><i>Programming Language - C, ANSI X3.159-1989: Input/Output (<b>stdio.h</b>), </i><hr><a name="open"></a><p align=right><a href="rtnIndex.html"><i>Libraries : Routines</i></a></p></blockquote><h1><i>open</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>open</i>( )</strong> - open a file</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int open ( const char * name, /* name of the file to open */ int flags, /* O_RDONLY, O_WRONLY, O_RDWR, or O_CREAT */ int mode /* mode of file to create (UNIX chmod style) */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine opens a file for reading, writing, or updating, and returnsa file descriptor for that file. The arguments to <b><i><a href="./ioLib.html#open">open</a></i>( )</b> are the filename and the type of access:<p><table><tr valign=top><td align=left><b>O_RDONLY</b> (0) </td><td align=left>(or READ) </td><td align=left>- open for reading only.</tr><tr valign=top><td align=left><b>O_WRONLY</b> (1) </td><td align=left>(or WRITE) </td><td align=left>- open for writing only.</tr><tr valign=top><td align=left><b>O_RDWR</b> (2) </td><td align=left>(or UPDATE) </td><td align=left>- open for reading and writing.</tr><tr valign=top><td align=left><b>O_CREAT</b> (0x0200)</td><td align=left> </td><td align=left>- create a file.</tr><tr valign=top><td align=left></tr></tr></table>In general, <b><i><a href="./ioLib.html#open">open</a></i>( )</b> can only open pre-existing devices and files. However,for NFS network devices only, files can also be created with <b><i><a href="./ioLib.html#open">open</a></i>( )</b> byperforming a logical OR operation with <b>O_CREAT</b> and the <i>flags</i> argument.In this case, the file is created with a UNIX chmod-style file mode, asindicated with <i>mode</i>. For example:<pre> fd = open ("/usr/myFile", O_CREAT | O_RDWR, 0644);</pre>Only the NFS driver uses the <i>mode</i> argument.<p></blockquote><h4>NOTE</h4><blockquote><p>For more information about situations when there are no file descriptorsavailable, see the manual entry for <b><i><a href="./iosLib.html#iosInit">iosInit</a></i>( )</b>.<p></blockquote><h4>RETURNS</h4><blockquote><p><p>A file descriptor number, or ERROR if a file name is not specified, thedevice does not exist, no file descriptors are available, or the driverreturns ERROR.<p></blockquote><h4>ERRNO</h4><blockquote><p>ELOOP<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ioLib.html#top">ioLib</a></b>, <b><i><a href="./ioLib.html#creat">creat</a></i>( )</b><p>VARARGS2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -