| 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(__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 int readdir_r(DIR *, struct dirent *, struct dirent **);
|
|---|
| 75 | extern void seekdir(DIR *, long);
|
|---|
| 76 | extern long telldir(DIR *);
|
|---|
| 77 | extern void closedir(DIR *);
|
|---|
| 78 | #define rewinddir(dirp) seekdir(dirp, 0L)
|
|---|
| 79 |
|
|---|
| 80 | extern char * abs_path(const char *name, char *buffer, int len);
|
|---|
| 81 |
|
|---|
| 82 | #ifndef S_IFMT
|
|---|
| 83 | #define S_IFMT ( S_IFDIR | S_IFREG )
|
|---|
| 84 | #endif
|
|---|
| 85 |
|
|---|
| 86 | #ifndef S_ISDIR
|
|---|
| 87 | #define S_ISDIR( m ) (((m) & S_IFMT) == S_IFDIR)
|
|---|
| 88 | #endif
|
|---|
| 89 |
|
|---|
| 90 | #ifndef S_ISREG
|
|---|
| 91 | #define S_ISREG( m ) (((m) & S_IFMT) == S_IFREG)
|
|---|
| 92 | #endif
|
|---|
| 93 |
|
|---|
| 94 | #ifdef __cplusplus
|
|---|
| 95 | }
|
|---|
| 96 | #endif
|
|---|
| 97 |
|
|---|
| 98 | #endif
|
|---|