1 #ifndef __DIRENT_H__ 2 #define __DIRENT_H__ 3 /* 4 * @(#)msd_dir.h 1.4 87/11/06 Public Domain. 5 * 6 * A public domain implementation of BSD directory routines for 7 * MS-DOS. Written by Michael Rendell ({uunet,utai}michael@garfield), 8 * August 1897 9 * 10 * Extended by Peter Lim (lim@mullian.oz) to overcome some MS DOS quirks 11 * and returns 2 more pieces of information - file size & attribute. 12 * Plus a little reshuffling of some #define's positions December 1987 13 * 14 * Some modifications by Martin Junius 02-14-89 15 * 16 * AK900712 17 * AK910410 abs_path - make absolute path 18 * 19 */ 20 21 #ifdef __EMX__ 22 #include <sys/param.h> 23 #else 24 #if defined(__IBMC__) || defined(__IBMCPP__) || defined(XP_W32_MSVC) 25 #include <stdio.h> 26 #ifdef MAXPATHLEN 27 #undef MAXPATHLEN 28 #endif 29 #define MAXPATHLEN (FILENAME_MAX * 4) 30 #define MAXNAMLEN FILENAME_MAX 31 32 #else 33 #include <param.h> 34 #endif 35 #endif 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 /* attribute stuff */ 42 #ifndef A_RONLY 43 #define A_RONLY 0x01 44 #define A_HIDDEN 0x02 45 #define A_SYSTEM 0x04 46 #define A_LABEL 0x08 47 #define A_DIR 0x10 48 #define A_ARCHIVE 0x20 49 #endif 50 51 struct dirent { 52 #if defined(OS2) || defined(WIN32) /* use the layout of EMX to avoid trouble */ 53 int d_ino; /* Dummy */ 54 int d_reclen; /* Dummy, same as d_namlen */ 55 int d_namlen; /* length of name */ 56 char d_name[MAXNAMLEN + 1]; 57 unsigned long d_size; 58 unsigned short d_attribute; /* attributes (see above) */ 59 unsigned short d_time; /* modification time */ 60 unsigned short d_date; /* modification date */ 61 #else 62 char d_name[MAXNAMLEN + 1]; /* garentee null termination */ 63 char d_attribute; /* .. extension .. */ 64 unsigned long d_size; /* .. extension .. */ 65 #endif 66 }; 67 68 typedef struct _dirdescr DIR; 69 /* the structs do not have to be defined here */ 70 71 extern DIR *opendir(const char *); 72 extern DIR *openxdir(const char *, unsigned); 73 extern struct dirent *readdir(DIR *); 74 extern void seekdir(DIR *, long); 75 extern long telldir(DIR *); 76 extern void closedir(DIR *); 77 #define rewinddir(dirp) seekdir(dirp, 0L) 78 79 extern char *abs_path(const char *name, char *buffer, int len); 80 81 #ifndef S_IFMT 82 #define S_IFMT (S_IFDIR | S_IFREG) 83 #endif 84 85 #ifndef S_ISDIR 86 #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) 87 #endif 88 89 #ifndef S_ISREG 90 #define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) 91 #endif 92 93 #ifdef __cplusplus 94 } 95 #endif 96 97 #endif 98