亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? library_13.html

?? Glibc的中文手冊
?? HTML
?? 第 1 頁 / 共 5 頁
字號:
<!-- This HTML file has been created by texi2html 1.27
     from library.texinfo on 3 March 1994 -->

<TITLE>The GNU C Library - File System Interface</TITLE>
<P>Go to the <A HREF="library_12.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_12.html">previous</A>, <A HREF="library_14.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_14.html">next</A> section.<P>
<H1><A NAME="SEC187" HREF="library_toc.html#SEC187" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC187">File System Interface</A></H1>
<P>
This chapter describes the GNU C library's functions for manipulating
files.  Unlike the input and output functions described in
section <A HREF="library_11.html#SEC117" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_11.html#SEC117">Input/Output on Streams</A> and section <A HREF="library_12.html#SEC171" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_12.html#SEC171">Low-Level Input/Output</A>, these
functions are concerned with operating on the files themselves, rather
than on their contents.
<P>
Among the facilities described in this chapter are functions for
examining or modifying directories, functions for renaming and deleting
files, and functions for examining and setting file attributes such as
access permissions and modification times.
<P>
<H2><A NAME="SEC188" HREF="library_toc.html#SEC188" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC188">Working Directory</A></H2>
<A NAME="IDX724"></A>
<A NAME="IDX725"></A>
<A NAME="IDX726"></A>
<P>
Each process has associated with it a directory, called its <DFN>current
working directory</DFN> or simply <DFN>working directory</DFN>, that is used in
the resolution of relative file names (see section <A HREF="library_10.html#SEC114" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_10.html#SEC114">File Name Resolution</A>).
<P>
When you log in and begin a new session, your working directory is
initially set to the home directory associated with your login account
in the system user database.  You can find any user's home directory
using the <CODE>getpwuid</CODE> or <CODE>getpwnam</CODE> functions; see section <A HREF="library_25.html#SEC441" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_25.html#SEC441">User Database</A>.
<P>
Users can change the working directory using shell commands like
<CODE>cd</CODE>.  The functions described in this section are the primitives
used by those commands and by other programs for examining and changing
the working directory.
<A NAME="IDX727"></A>
<P>
Prototypes for these functions are declared in the header file
<TT>`unistd.h'</TT>.
<A NAME="IDX728"></A>
<P>
<A NAME="IDX729"></A>
<U>Function:</U> char * <B>getcwd</B> <I>(char *<VAR>buffer</VAR>, size_t <VAR>size</VAR>)</I><P>
The <CODE>getcwd</CODE> function returns an absolute file name representing
the current working directory, storing it in the character array
<VAR>buffer</VAR> that you provide.  The <VAR>size</VAR> argument is how you tell
the system the allocation size of <VAR>buffer</VAR>.
<P>
The GNU library version of this function also permits you to specify a
null pointer for the <VAR>buffer</VAR> argument.  Then <CODE>getcwd</CODE>
allocates a buffer automatically, as with <CODE>malloc</CODE>
(see section <A HREF="library_3.html#SEC21" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_3.html#SEC21">Unconstrained Allocation</A>).  If the <VAR>size</VAR> is greater than
zero, then the buffer is that large; otherwise, the buffer is as large
as necessary to hold the result.
<P>
The return value is <VAR>buffer</VAR> on success and a null pointer on failure.
The following <CODE>errno</CODE> error conditions are defined for this function:
<P>
<DL COMPACT>
<DT><CODE>EINVAL</CODE>
<DD>The <VAR>size</VAR> argument is zero and <VAR>buffer</VAR> is not a null pointer.
<P>
<DT><CODE>ERANGE</CODE>
<DD>The <VAR>size</VAR> argument is less than the length of the working directory
name.  You need to allocate a bigger array and try again.
<P>
<DT><CODE>EACCES</CODE>
<DD>Permission to read or search a component of the file name was denied.
</DL>
<P>
Here is an example showing how you could implement the behavior of GNU's
<CODE>getcwd (NULL, 0)</CODE> using only the standard behavior of
<CODE>getcwd</CODE>:
<P>
<PRE>
char *
gnu_getcwd ()
{
  int size = 100;
  char *buffer = (char *) xmalloc (size);

  while (1)
    {
      char *value = getcwd (buffer, size);
      if (value != 0)
        return buffer;
      size *= 2;
      free (buffer);
      buffer = (char *) xmalloc (size);
    }
}
</PRE>
<P>
See section <A HREF="library_3.html#SEC23" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_3.html#SEC23">Examples of <CODE>malloc</CODE></A>, for information about <CODE>xmalloc</CODE>, which is
not a library function but is a customary name used in most GNU
software.
<P>
<A NAME="IDX730"></A>
<U>Function:</U> char * <B>getwd</B> <I>(char *<VAR>buffer</VAR>)</I><P>
This is similar to <CODE>getcwd</CODE>.  The GNU library provides <CODE>getwd</CODE>
for backwards compatibility with BSD.  The <VAR>buffer</VAR> should be a
pointer to an array at least <CODE>PATH_MAX</CODE> bytes long.
<P>
<A NAME="IDX731"></A>
<U>Function:</U> int <B>chdir</B> <I>(const char *<VAR>filename</VAR>)</I><P>
This function is used to set the process's working directory to
<VAR>filename</VAR>.
<P>
The normal, successful return value from <CODE>chdir</CODE> is <CODE>0</CODE>.  A
value of <CODE>-1</CODE> is returned to indicate an error.  The <CODE>errno</CODE>
error conditions defined for this function are the usual file name
syntax errors (see section <A HREF="library_10.html#SEC115" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_10.html#SEC115">File Name Errors</A>), plus <CODE>ENOTDIR</CODE> if the
file <VAR>filename</VAR> is not a directory.
<P>
<A NAME="IDX732"></A>
<A NAME="IDX733"></A>
<A NAME="IDX734"></A>
<H2><A NAME="SEC189" HREF="library_toc.html#SEC189" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC189">Accessing Directories</A></H2>
<P>
The facilities described in this section let you read the contents of a
directory file.  This is useful if you want your program to list all the
files in a directory, perhaps as part of a menu.
<A NAME="IDX735"></A>
<P>
The <CODE>opendir</CODE> function opens a <DFN>directory stream</DFN> whose
elements are directory entries.  You use the <CODE>readdir</CODE> function on
the directory stream to retrieve these entries, represented as
<CODE>struct dirent</CODE> objects.  The name of the file for each entry is
stored in the <CODE>d_name</CODE> member of this structure.  There are obvious
parallels here to the stream facilities for ordinary files, described in
section <A HREF="library_11.html#SEC117" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_11.html#SEC117">Input/Output on Streams</A>.
<P>
<H3><A NAME="SEC190" HREF="library_toc.html#SEC190" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC190">Format of a Directory Entry</A></H3>
<A NAME="IDX736"></A>
<P>
This section describes what you find in a single directory entry, as you
might obtain it from a directory stream.  All the symbols are declared
in the header file <TT>`dirent.h'</TT>.
<P>
<A NAME="IDX737"></A>
<U>Data Type:</U> <B>struct dirent</B><P>
This is a structure type used to return information about directory
entries.  It contains the following fields:
<P>
<DL COMPACT>
<DT><CODE>char *d_name</CODE>
<DD>This is the null-terminated file name component.  This is the only
field you can count on in all POSIX systems.
<P>
<DT><CODE>ino_t d_fileno</CODE>
<DD>This is the file serial number.  For BSD compatibility, you can also
refer to this member as <CODE>d_ino</CODE>.
<P>
<DT><CODE>size_t d_namlen</CODE>
<DD>This is the length of the file name, not including the terminating null
character.
</DL>
<P>
This structure may contain additional members in the future.
<P>
When a file has multiple names, each name has its own directory entry.
The only way you can tell that the directory entries belong to a
single file is that they have the same value for the <CODE>d_fileno</CODE>
field.
<P>
File attributes such as size, modification times, and the like are part
of the file itself, not any particular directory entry.  See section <A HREF="library_13.html#SEC200" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_13.html#SEC200">File Attributes</A>.
<P>
<H3><A NAME="SEC191" HREF="library_toc.html#SEC191" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC191">Opening a Directory Stream</A></H3>
<A NAME="IDX738"></A>
<P>
This section describes how to open a directory stream.  All the symbols
are declared in the header file <TT>`dirent.h'</TT>.
<P>
<A NAME="IDX739"></A>
<U>Data Type:</U> <B>DIR</B><P>
The <CODE>DIR</CODE> data type represents a directory stream.  
<P>
You shouldn't ever allocate objects of the <CODE>struct dirent</CODE> or
<CODE>DIR</CODE> data types, since the directory access functions do that for
you.  Instead, you refer to these objects using the pointers returned by
the following functions.
<P>
<A NAME="IDX740"></A>
<U>Function:</U> DIR * <B>opendir</B> <I>(const char *<VAR>dirname</VAR>)</I><P>
The <CODE>opendir</CODE> function opens and returns a directory stream for
reading the directory whose file name is <VAR>dirname</VAR>.  The stream has
type <CODE>DIR *</CODE>.
<P>
If unsuccessful, <CODE>opendir</CODE> returns a null pointer.  In addition to
the usual file name syntax errors (see section <A HREF="library_10.html#SEC115" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_10.html#SEC115">File Name Errors</A>), the
following <CODE>errno</CODE> error conditions are defined for this function:
<P>
<DL COMPACT>
<DT><CODE>EACCES</CODE>
<DD>Read permission is denied for the directory named by <CODE>dirname</CODE>.
<P>
<DT><CODE>EMFILE</CODE>
<DD>The process has too many files open.
<P>
<DT><CODE>ENFILE</CODE>
<DD>The entire system, or perhaps the file system which contains the
directory, cannot support any additional open files at the moment.
(This problem cannot happen on the GNU system.)
</DL>
<P>
The <CODE>DIR</CODE> type is typically implemented using a file descriptor,
and the <CODE>opendir</CODE> function in terms of the <CODE>open</CODE> function.
See section <A HREF="library_12.html#SEC171" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_12.html#SEC171">Low-Level Input/Output</A>.  Directory streams and the underlying
file descriptors are closed on <CODE>exec</CODE> (see section <A HREF="library_23.html#SEC406" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_23.html#SEC406">Executing a File</A>).
<P>
<H3><A NAME="SEC192" HREF="library_toc.html#SEC192" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC192">Reading and Closing a Directory Stream</A></H3>
<A NAME="IDX741"></A>
<P>
This section describes how to read directory entries from a directory
stream, and how to close the stream when you are done with it.  All the
symbols are declared in the header file <TT>`dirent.h'</TT>.
<P>
<A NAME="IDX742"></A>
<U>Function:</U> struct dirent * <B>readdir</B> <I>(DIR *<VAR>dirstream</VAR>)</I><P>
This function reads the next entry from the directory.  It normally
returns a pointer to a structure containing information about the file.
This structure is statically allocated and can be rewritten by a
subsequent call.
<P>
<STRONG>Portability Note:</STRONG> On some systems, <CODE>readdir</CODE> may not
return entries for <TT>`.'</TT> and <TT>`..'</TT>.  See section <A HREF="library_10.html#SEC114" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_10.html#SEC114">File Name Resolution</A>.
<P>
If there are no more entries in the directory or an error is detected,
<CODE>readdir</CODE> returns a null pointer.  The following <CODE>errno</CODE> error
conditions are defined for this function:
<P>
<DL COMPACT>
<DT><CODE>EBADF</CODE>
<DD>The <VAR>dirstream</VAR> argument is not valid.
</DL>
<P>
<A NAME="IDX743"></A>
<U>Function:</U> int <B>closedir</B> <I>(DIR *<VAR>dirstream</VAR>)</I><P>
This function closes the directory stream <VAR>dirstream</VAR>.  It returns
<CODE>0</CODE> on success and <CODE>-1</CODE> on failure.  
<P>
The following <CODE>errno</CODE> error conditions are defined for this
function:
<P>
<DL COMPACT>
<DT><CODE>EBADF</CODE>
<DD>The <VAR>dirstream</VAR> argument is not valid.
</DL>
<P>
<H3><A NAME="SEC193" HREF="library_toc.html#SEC193" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC193">Simple Program to List a Directory</A></H3>
<P>
Here's a simple program that prints the names of the files in
the current working directory:
<P>
<PRE>
#include &#60;stddef.h&#62;
#include &#60;stdio.h&#62;
#include &#60;sys/types.h&#62;
#include &#60;dirent.h&#62;

int
main (void)
{
  DIR *dp;
  struct dirent *ep;

  dp = opendir ("./");
  if (dp != NULL)
    {
      while (ep = readdir (dp))
	puts (ep-&#62;d_name);
      (void) closedir (dp);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲va国产天堂va久久en| 国产精品一二三| 久久综合精品国产一区二区三区| 不卡视频免费播放| 日本91福利区| 亚洲乱码国产乱码精品精98午夜| 精品入口麻豆88视频| 色噜噜狠狠成人网p站| 国产精品影视天天线| 性感美女久久精品| 亚洲精品免费电影| 国产精品毛片久久久久久| 欧美tickling网站挠脚心| 欧美日韩国产免费| 色综合久久综合网欧美综合网| 国产乱理伦片在线观看夜一区| 亚洲v日本v欧美v久久精品| 日韩伦理电影网| 中文字幕精品在线不卡| xfplay精品久久| 日韩欧美一区二区不卡| 欧美日韩大陆一区二区| 欧美午夜不卡在线观看免费| 国产高清在线观看免费不卡| 麻豆精品久久久| 一片黄亚洲嫩模| 国产欧美精品一区二区色综合| 91精品国产一区二区三区蜜臀| 欧美在线你懂的| 色婷婷亚洲婷婷| av一区二区久久| 成人一区二区三区视频在线观看 | 日韩久久久久久| 欧美三级中文字| 在线观看日韩精品| 欧美性视频一区二区三区| 91麻豆.com| 色婷婷亚洲综合| 91黄色激情网站| 欧美艳星brazzers| 欧美精品一卡二卡| 欧美美女喷水视频| 日韩一区二区在线免费观看| 7777精品伊人久久久大香线蕉的 | 99re在线精品| av一区二区久久| 91麻豆高清视频| 在线精品视频小说1| 91福利视频在线| 欧美系列亚洲系列| 4438成人网| 日韩精品一区二区三区视频| 久久综合久久久久88| 国产女同互慰高潮91漫画| 欧美激情艳妇裸体舞| 一区在线播放视频| 亚洲狠狠爱一区二区三区| 天天av天天翘天天综合网色鬼国产| 婷婷亚洲久悠悠色悠在线播放| 首页综合国产亚洲丝袜| 另类小说图片综合网| 高清国产一区二区三区| 99国产欧美久久久精品| 欧美三区在线观看| 精品免费99久久| 国产精品嫩草影院com| 亚洲乱码中文字幕| 日本免费在线视频不卡一不卡二 | 色视频欧美一区二区三区| 欧美丝袜自拍制服另类| 日韩一二在线观看| 久久久电影一区二区三区| 亚洲欧美激情一区二区| 日韩av二区在线播放| 懂色av一区二区夜夜嗨| 精品视频在线免费观看| 欧美精品一区二区三区一线天视频 | 亚洲一区免费在线观看| 免费观看30秒视频久久| 99视频精品全部免费在线| 欧美另类久久久品| 国产无遮挡一区二区三区毛片日本| 成人欧美一区二区三区黑人麻豆| 性欧美疯狂xxxxbbbb| 国产成人综合视频| 欧美日韩在线精品一区二区三区激情 | 国产精品白丝jk黑袜喷水| 91亚洲资源网| 日韩精品专区在线| 一区二区三区精品在线| 国产伦精品一区二区三区在线观看| 91欧美一区二区| 精品88久久久久88久久久| 亚洲国产你懂的| 成人av在线电影| 欧美一级午夜免费电影| 亚洲欧美另类久久久精品| 国产毛片精品视频| 制服.丝袜.亚洲.中文.综合| 国产精品久久国产精麻豆99网站| 日韩电影在线一区| 色999日韩国产欧美一区二区| 久久久久久久综合| 日日噜噜夜夜狠狠视频欧美人| av影院午夜一区| 国产午夜精品一区二区| 日韩和的一区二区| 91浏览器打开| 美女任你摸久久| 欧美体内she精高潮| 自拍视频在线观看一区二区| 国产美女一区二区| 日韩欧美美女一区二区三区| 亚洲一本大道在线| 色诱视频网站一区| 国产精品入口麻豆原神| 国产伦精品一区二区三区在线观看| 欧美精品v日韩精品v韩国精品v| 亚洲另类春色校园小说| 99精品视频免费在线观看| 国产色爱av资源综合区| 九九在线精品视频| 欧美一区二区三区四区五区| 亚洲va韩国va欧美va| 欧美在线一区二区| 亚洲一区二区视频在线| 在线看一区二区| 亚洲黄色片在线观看| 91网址在线看| 亚洲精品国久久99热| 不卡视频免费播放| 中文字幕一区二区在线播放| 成人性生交大合| 国产精品免费久久| 国产91在线看| 国产精品免费丝袜| 不卡一区二区在线| 亚洲欧美区自拍先锋| 色av综合在线| 午夜视频在线观看一区| 欧美日韩一区在线观看| 九九九久久久精品| 欧美日韩一区久久| 日一区二区三区| 日韩精品一区二区三区三区免费| 强制捆绑调教一区二区| 日韩美女在线视频| 国产精选一区二区三区| 中日韩免费视频中文字幕| 91同城在线观看| 亚洲制服丝袜av| 欧美一级欧美三级在线观看| 麻豆专区一区二区三区四区五区| 精品福利一区二区三区免费视频| 国产麻豆精品久久一二三| 奇米一区二区三区av| 久久蜜臀中文字幕| 99精品国产一区二区三区不卡| 亚洲无人区一区| 日韩免费观看高清完整版| 国产成人综合亚洲网站| 亚洲狼人国产精品| 欧美一区在线视频| 国产河南妇女毛片精品久久久| 中文字幕一区二区视频| 欧美日韩大陆一区二区| 国产乱理伦片在线观看夜一区| 亚洲三级电影网站| 欧美一区二区精品| 成人高清在线视频| 亚洲bdsm女犯bdsm网站| 久久午夜国产精品| 91黄色小视频| 玖玖九九国产精品| 亚洲欧洲成人自拍| 欧美一卡二卡三卡| 成人激情文学综合网| 日韩精品国产精品| 国产精品久线在线观看| 91精品在线麻豆| 成人毛片视频在线观看| 亚洲成a天堂v人片| 亚洲国产成人私人影院tom| 欧美日韩精品一区二区| 国产91丝袜在线播放| 天天操天天色综合| 亚洲欧美在线观看| 欧美xingq一区二区| 在线亚洲欧美专区二区| 日韩国产精品久久久久久亚洲| 亚洲国产激情av| 欧美成人综合网站| 色综合婷婷久久| 国产麻豆欧美日韩一区| 日一区二区三区| 一区二区三区中文在线| 国产日韩精品一区二区三区 | 久久精品免视看| 欧美日本国产一区| 91麻豆免费看|