michael@0: #ifndef __DIRENT_H__ michael@0: #define __DIRENT_H__ michael@0: /* michael@0: * @(#)msd_dir.h 1.4 87/11/06 Public Domain. michael@0: * michael@0: * A public domain implementation of BSD directory routines for michael@0: * MS-DOS. Written by Michael Rendell ({uunet,utai}michael@garfield), michael@0: * August 1897 michael@0: * michael@0: * Extended by Peter Lim (lim@mullian.oz) to overcome some MS DOS quirks michael@0: * and returns 2 more pieces of information - file size & attribute. michael@0: * Plus a little reshuffling of some #define's positions December 1987 michael@0: * michael@0: * Some modifications by Martin Junius 02-14-89 michael@0: * michael@0: * AK900712 michael@0: * AK910410 abs_path - make absolute path michael@0: * michael@0: */ michael@0: michael@0: #ifdef __EMX__ michael@0: #include michael@0: #else michael@0: #if defined(__IBMC__) || defined(__IBMCPP__) || defined(XP_W32_MSVC) michael@0: #include michael@0: #ifdef MAXPATHLEN michael@0: #undef MAXPATHLEN michael@0: #endif michael@0: #define MAXPATHLEN (FILENAME_MAX*4) michael@0: #define MAXNAMLEN FILENAME_MAX michael@0: michael@0: #else michael@0: #include michael@0: #endif michael@0: #endif michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" { michael@0: #endif michael@0: michael@0: /* attribute stuff */ michael@0: #ifndef A_RONLY michael@0: # define A_RONLY 0x01 michael@0: # define A_HIDDEN 0x02 michael@0: # define A_SYSTEM 0x04 michael@0: # define A_LABEL 0x08 michael@0: # define A_DIR 0x10 michael@0: # define A_ARCHIVE 0x20 michael@0: #endif michael@0: michael@0: struct dirent { michael@0: #if defined(OS2) || defined(WIN32) /* use the layout of EMX to avoid trouble */ michael@0: int d_ino; /* Dummy */ michael@0: int d_reclen; /* Dummy, same as d_namlen */ michael@0: int d_namlen; /* length of name */ michael@0: char d_name[MAXNAMLEN + 1]; michael@0: unsigned long d_size; michael@0: unsigned short d_attribute; /* attributes (see above) */ michael@0: unsigned short d_time; /* modification time */ michael@0: unsigned short d_date; /* modification date */ michael@0: #else michael@0: char d_name[MAXNAMLEN + 1]; /* garentee null termination */ michael@0: char d_attribute; /* .. extension .. */ michael@0: unsigned long d_size; /* .. extension .. */ michael@0: #endif michael@0: }; michael@0: michael@0: typedef struct _dirdescr DIR; michael@0: /* the structs do not have to be defined here */ michael@0: michael@0: extern DIR *opendir(const char *); michael@0: extern DIR *openxdir(const char *, unsigned); michael@0: extern struct dirent *readdir(DIR *); michael@0: extern void seekdir(DIR *, long); michael@0: extern long telldir(DIR *); michael@0: extern void closedir(DIR *); michael@0: #define rewinddir(dirp) seekdir(dirp, 0L) michael@0: michael@0: extern char * abs_path(const char *name, char *buffer, int len); michael@0: michael@0: #ifndef S_IFMT michael@0: #define S_IFMT ( S_IFDIR | S_IFREG ) michael@0: #endif michael@0: michael@0: #ifndef S_ISDIR michael@0: #define S_ISDIR( m ) (((m) & S_IFMT) == S_IFDIR) michael@0: #endif michael@0: michael@0: #ifndef S_ISREG michael@0: #define S_ISREG( m ) (((m) & S_IFMT) == S_IFREG) michael@0: #endif michael@0: michael@0: #ifdef __cplusplus michael@0: } michael@0: #endif michael@0: michael@0: #endif