藍森林首頁 | 返回主頁 | 本站地圖 | 站內搜索 | 聯繫信箱 |
 您目前的位置:首頁 > 自由軟件 > 技術交流 > 應用編程


    

藍森林 http://www.lslnet.com 2006年6月6日 10:18


DIR 的數據結構??

用grep在/usr/include下搜索了一下
怎麼會沒找到?

DIR 的數據結構??

你好像什麼參數都沒有,或者你那個目錄裡面根本就沒有!

DIR 的數據結構??

只知道跟FILE像似
有個成員 char d_name ;
那位知道其具體結構
3Q

DIR 的數據結構??

/usr/include/dirent.h

DIR 的數據結構??

dirent.h裡面定義
typedef  struct  __dirstream DIR;


好像對DIR是隱藏的;

順便問一下,在VI中要同時找兩個單詞的命令是什麼?

DIR 的數據結構??

定義在<dirent.h>;中的dirent結構與實現有關,
但至少有兩個成員
struct dirent
{
ino_t d_ino ;/* i-node number */
char d_name(NAMR_MAX+1);/* null-terminated filename */
}
<dirent.h>;中沒有,你可以查一查他包含的頭文件,應該有的

我也是新手,大家互相學習

DIR 的數據結構??

定義在<dirent.h>;中的dirent結構與實現有關,
但至少有兩個成員
struct dirent
{
ino_t d_ino ;/* i-node number */
char d_name(NAMR_MAX+1);/* null-terminated filename */
}
<dirent.h>;中沒有,你可以查一查他包含的頭文件,應該有的

我也是新手,大家互相學習

DIR 的數據結構??

定義在<dirent.h>;中的dirent結構與實現有關,
但至少有兩個成員
struct dirent
{
ino_t d_ino ;/* i-node number */
char d_name(NAMR_MAX+1);/* null-terminated filename */
}
<dirent.h>;中沒有,你可以查一查他包含的頭文件,應該有的

我也是新手,大家互相學習

DIR 的數據結構??

dirent.h頭文件裡面有註釋說其結構是不可見的

DIR 的數據結構??

我以前在Solaris的include下
找到過這個結構.
你那裡為什麼不可見,我就不知到了.

DIR 的數據結構??

我讓你看看aix的。
[code]
typedef struct _dirdesc {
#ifdef _ALL_SOURCE
        int     dd_fd;          /* file descriptor of directory */
        blksize_t dd_blksize;   /* this filesystem's block size */
        char    *dd_buf;        /* malloc'd buffer depending of fs bsize */
        long    dd_size;        /* size of buffer */
        long    dd_flag;        /* private flags for readdir, unused */
        off_t   dd_loc;         /* logical(dirent) offset in  directory */
        off_t   dd_curoff;      /* real offset in directory corresponding
                                 * to dd_loc */
#else
        int     __dd_fd;                /* file descriptor of directory */
        blksize_t __dd_blksize; /* this filesystem's block size */
        char    *__dd_buf;      /* malloc'd buffer depending of fs bsize */
        long    __dd_size;      /* size of buffer */
        long    __dd_flag;      /* private flags for readdir, unused */
        off_t   __dd_loc;       /* logical(dirent) offset in  directory */
        off_t   __dd_curoff;    /* real offset in directory corresponding
                                 * to dd_loc */
#endif
#ifdef _THREAD_SAFE
        void    *dd_lock;       /* for inter-thread locking */
#endif

} DIR;
[/code]
/usr/include/sys/dir.h

DIR 的數據結構??

[code]/* Directory stream type.

   The miscellaneous Unix `readdir' implementations read directory data
   into a buffer and return `struct dirent *' pointers into it.  */

struct __dirstream
  {
    int fd;                        /* File descriptor.  */

    char *data;                        /* Directory block.  */
    size_t allocation;                /* Space allocated for the block.  */
    size_t size;                /* Total valid data in the block.  */
    size_t offset;                /* Current offset into the block.  */

    off_t filepos;                /* Position of next entry to read.  */

    __libc_lock_define (, lock) /* Mutex lock for this structure.  */
  };[/code]


glibc source code
path: sysdeps/unix/dirstream.h

DIR 的數據結構??

3Q very much



Copyright © 1999-2000 LSLNET.COM. All rights reserved. 藍森林網站 版權所有。 E-mail : webmaster@lslnet.com