#ifndef DIRENT_H
#define DIRENT_H

/*
**          $VER: dirent.h 1.4 (30.12.00)
**             Includes Release 45.00
**                 StormC Version
**
**    Copyright © 1996/2001 by CyberdyneSystems
**
**            written by Matthias Henze
**               All Rights Reserved
*/

#ifndef STORMAMIGA_H
  #include <stormamiga.h>
#endif
#ifndef SYS_DIRENT_H
  #include <sys/dirent.h>
#endif

#ifdef __cplusplus
  extern "C" {
#endif

#ifdef _POSIX_SOURCE
  typedef void *  DIR;
#else

/* backwards compatibility */
#define d_ino           d_fileno

/* definitions for library routines operating on directories. */
#define DIRBLKSIZ       1024

/* structure describing an open directory. */
#ifdef STORMAMIGA_SASC
  typedef struct _dirdesc
  {
    long    dd_fd;        /* system directory lock   */
    long    dd_loc;       /* current directory posn  */
    long    dd_size;      /* size of dd_buf in bytes */
    char    *dd_buf;      /* system structure info   */
  } DIR;
#else
  typedef struct _dirdesc
  {
    int     dd_fd;        /* file descriptor associated with directory */
    struct dirent dd_ent;
  } DIR;
#endif

#define dirfd(dirp)     ((dirp)->dd_fd)
#endif /* _POSIX_SOURCE */

DIR     *opendir        (cchar *);
struct dirent *readdir  (DIR *);
void    rewinddir       (DIR *);
int     closedir        (DIR *);

#ifdef __cplusplus
  }
#endif

#ifdef STORMAMIGA_UNIXPATH
  extern "C" {char *UnixToAmigaPath (cchar *);}

  __inline DIR *opendir_u (cchar *name)
  { return opendir ((UnixToAmigaPath(name)); }

  #define opendir opendir_u
#endif

#endif  /* DIRENT_H */

