1 
2 /* ---------------------------------------------------------------------------
3     Stuff to fake unix file I/O on windows boxes
4     ------------------------------------------------------------------------*/
5 
6 #ifndef WINFILE_H
7 #define WINFILE_H
8 
9 #ifdef _WINDOWS
10 /* hacked out of <dirent.h> on an SGI */
11 #if defined(XP_WIN32) || defined(_WIN32)
12 /* 32-bit stuff here */
13 #include <windows.h>
14 #include <stdlib.h>
15 #ifdef __MINGW32__
16 #include <sys/types.h>
17 #include <sys/stat.h>
18 #else
19 #include <sys\types.h>
20 #include <sys\stat.h>
21 #endif
22 
23 typedef struct DIR_Struct {
24     void* directoryPtr;
25     WIN32_FIND_DATA data;
26 } DIR;
27 
28 #define _ST_FSTYPSZ 16
29 
30 #if !defined(__BORLANDC__) && !defined(__GNUC__)
31 typedef unsigned long mode_t;
32 typedef long uid_t;
33 typedef long gid_t;
34 typedef long off_t;
35 typedef unsigned long nlink_t;
36 #endif
37 
38 typedef struct timestruc {
39     time_t tv_sec; /* seconds */
40     long tv_nsec;  /* and nanoseconds */
41 } timestruc_t;
42 
43 struct dirent {              /* data from readdir() */
44     ino_t d_ino;             /* inode number of entry */
45     off_t d_off;             /* offset of disk direntory entry */
46     unsigned short d_reclen; /* length of this record */
47     char d_name[_MAX_FNAME]; /* name of file */
48 };
49 
50 #if !defined(__BORLANDC__) && !defined(__GNUC__)
51 #define S_ISDIR(s) ((s)&_S_IFDIR)
52 #endif
53 
54 #else /* _WIN32 */
55 /* 16-bit windows stuff */
56 
57 #include <sys\types.h>
58 #include <sys\stat.h>
59 #include <dos.h>
60 
61 /*	Getting cocky to support multiple file systems */
62 typedef struct dirStruct_tag {
63     struct _find_t file_data;
64     char c_checkdrive;
65 } dirStruct;
66 
67 typedef struct DIR_Struct {
68     void* directoryPtr;
69     dirStruct data;
70 } DIR;
71 
72 #define _ST_FSTYPSZ 16
73 typedef unsigned long mode_t;
74 typedef long uid_t;
75 typedef long gid_t;
76 typedef long off_t;
77 typedef unsigned long nlink_t;
78 
79 typedef struct timestruc {
80     time_t tv_sec; /* seconds */
81     long tv_nsec;  /* and nanoseconds */
82 } timestruc_t;
83 
84 struct dirent {              /* data from readdir() */
85     ino_t d_ino;             /* inode number of entry */
86     off_t d_off;             /* offset of disk direntory entry */
87     unsigned short d_reclen; /* length of this record */
88 #ifdef XP_WIN32
89     char d_name[_MAX_FNAME]; /* name of file */
90 #else
91     char d_name[20]; /* name of file */
92 #endif
93 };
94 
95 #define S_ISDIR(s) ((s)&_S_IFDIR)
96 
97 #endif /* 16-bit windows */
98 
99 #define CONST const
100 
101 #endif /* _WINDOWS */
102 
103 #endif /* WINFILE_H */
104