home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / DEV.Z / dirent.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-08  |  3.1 KB  |  116 lines

  1. /* Copyright (C) 1991 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. /*
  20.  *    POSIX Standard: 5.1.2 Directory Operations    <dirent.h>
  21.  *
  22.  *      modified for the WIN32 Subsystem
  23.  */
  24.  
  25. #ifndef    _DIRENT_H
  26.  
  27. #define    _DIRENT_H    
  28. /*
  29. #include <features.h>
  30.  
  31. #include <gnu/types.h>
  32. */
  33.  
  34. #include <stdlib.h>
  35. #define MAXNAMLEN _MAX_FNAME
  36.  
  37. #define    __need_size_t
  38. #include <stddef.h>
  39. #include <sys/types.h>
  40.  
  41.  
  42. /* Directory entry structure.  */
  43. struct dirent
  44.   {
  45.     _ino_t d_fileno;    /* File serial number.  */
  46.     size_t d_namlen;    /* Length of the file name.  */
  47.  
  48.     /* Only this member is in the POSIX standard.  */
  49.     char d_name[1];    /* File name (actually longer).  */
  50.   };
  51.  
  52. #if defined(__USE_BSD) || defined(__USE_MISC)
  53. #define    d_ino        d_fileno    /* Backward compatibility.  */
  54. #endif
  55.  
  56. /* Directory stream type.  */
  57. typedef struct
  58.   {
  59.     int __fd;            /* File descriptor.  */
  60.  
  61.     char *__data;        /* Directory block.  */
  62.     size_t __allocation;    /* Space allocated for the block.  */
  63.     size_t __offset;        /* Current offset into the block.  */
  64.     size_t __size;        /* Total valid data in the block.  */
  65.  
  66.     struct dirent __entry;    /* Returned by `readdir'.  */
  67.   } DIR;
  68.  
  69.  
  70. /* Open a directory stream on NAME.
  71.    Return a DIR stream on the directory, or NULL if it could not be opened.  */
  72. extern DIR * opendir(char *__name);
  73.  
  74. /* Close the directory stream DIRP.
  75.    Return 0 if successful, -1 if not.  */
  76. extern int closedir(DIR *__dirp);
  77.  
  78. /* Read a directory entry from DIRP.
  79.    Return a pointer to a `struct dirent' describing the entry,
  80.    or NULL for EOF or error.  The storage returned may be overwritten
  81.    by a later readdir call on the same DIR stream.  */
  82. extern struct dirent *readdir(DIR *__dirp);
  83.  
  84. /* Rewind DIRP to the beginning of the directory.  */
  85. extern void rewinddir(DIR *__dirp);
  86.  
  87. #if defined(__USE_BSD) || defined(__USE_MISC)
  88.  
  89. #ifndef    MAXNAMLEN
  90. /* Get the definitions of the POSIX.1 limits.  */
  91. #include <posix1_lim.h>
  92.  
  93. /* `MAXNAMLEN' is the BSD name for what POSIX calls `NAME_MAX'.  */
  94. #ifdef    NAME_MAX
  95. #define    MAXNAMLEN    NAME_MAX
  96. #else
  97. #define    MAXNAMLEN    255
  98. #endif
  99. #endif
  100.  
  101. /*
  102. #include <gnu/types.h>
  103. */
  104.  
  105. /* Seek to position POS on DIRP.  */
  106. extern void seekdir(DIR *__dirp, _off_t __pos);
  107.  
  108. /* Return the current position of DIRP.  */
  109. extern _off_t telldir(DIR *__dirp);
  110.  
  111. #endif    /* Use BSD or misc.  */
  112.  
  113.  
  114. #endif    /* dirent.h  */
  115.  
  116.