当前位置: 技术问答>linux和unix
关于opendir函数的返回类型DIR
来源: 互联网 发布时间:2015-03-07
本文导语: 函数原型为: DIR *opendir(const char *pathname); 返回值数据类型为DIR,可是在包含文件中找到: typedef struct __dirstream DIR; 但找不到struct __dirstream的具体定义。 请问struct __dirstream在那里定义?是如何定义的? 谢谢! ...
函数原型为:
DIR *opendir(const char *pathname);
返回值数据类型为DIR,可是在包含文件中找到:
typedef struct __dirstream DIR;
但找不到struct __dirstream的具体定义。
请问struct __dirstream在那里定义?是如何定义的?
谢谢!
DIR *opendir(const char *pathname);
返回值数据类型为DIR,可是在包含文件中找到:
typedef struct __dirstream DIR;
但找不到struct __dirstream的具体定义。
请问struct __dirstream在那里定义?是如何定义的?
谢谢!
|
struct dirent
{
long d_ino; /* Always zero. */
unsigned short d_reclen; /* Always zero. */
unsigned short d_namlen; /* Length of name in d_name. */
char* d_name; /* File name. */
/* NOTE: The name in the dirent structure points to the name in the
* finddata_t structure in the DIR. */
};
typedef struct
{
/* disk transfer area for this dir */
struct _finddata_t dd_dta;
/* dirent struct to return from dir (NOTE: this makes this thread
* safe as long as only one thread uses a particular DIR struct at
* a time) */
struct dirent dd_dir;
/* _findnext handle */
long dd_handle;
/*
* Status of search:
* 0 = not started yet (next entry to read is first entry)
* -1 = off the end
* positive = 0 based index of next entry
*/
int dd_stat;
/* given path for dir with search pattern (struct is extended) */
char dd_name[1];
} DIR;
不想切入linux,我在windows下的MinGW里看了看,DIR是上面的定义。在dirent.h里。
{
long d_ino; /* Always zero. */
unsigned short d_reclen; /* Always zero. */
unsigned short d_namlen; /* Length of name in d_name. */
char* d_name; /* File name. */
/* NOTE: The name in the dirent structure points to the name in the
* finddata_t structure in the DIR. */
};
typedef struct
{
/* disk transfer area for this dir */
struct _finddata_t dd_dta;
/* dirent struct to return from dir (NOTE: this makes this thread
* safe as long as only one thread uses a particular DIR struct at
* a time) */
struct dirent dd_dir;
/* _findnext handle */
long dd_handle;
/*
* Status of search:
* 0 = not started yet (next entry to read is first entry)
* -1 = off the end
* positive = 0 based index of next entry
*/
int dd_stat;
/* given path for dir with search pattern (struct is extended) */
char dd_name[1];
} DIR;
不想切入linux,我在windows下的MinGW里看了看,DIR是上面的定义。在dirent.h里。
|
/* This is the data type of directory stream objects.
The actual structure is opaque to users. */
typedef struct __dirstream DIR;
这个结构对用户是不透明的. 你不用care, 只管用就是了. 就跟 FILE* 一样.
The actual structure is opaque to users. */
typedef struct __dirstream DIR;
这个结构对用户是不透明的. 你不用care, 只管用就是了. 就跟 FILE* 一样.