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