|
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 |
|
44 struct dirent { /* data from readdir() */ |
|
45 ino_t d_ino; /* inode number of entry */ |
|
46 off_t d_off; /* offset of disk direntory entry */ |
|
47 unsigned short d_reclen; /* length of this record */ |
|
48 char d_name[_MAX_FNAME]; /* name of file */ |
|
49 }; |
|
50 |
|
51 #if !defined(__BORLANDC__) && !defined (__GNUC__) |
|
52 #define S_ISDIR(s) ((s) & _S_IFDIR) |
|
53 #endif |
|
54 |
|
55 #else /* _WIN32 */ |
|
56 /* 16-bit windows stuff */ |
|
57 |
|
58 #include <sys\types.h> |
|
59 #include <sys\stat.h> |
|
60 #include <dos.h> |
|
61 |
|
62 |
|
63 |
|
64 /* Getting cocky to support multiple file systems */ |
|
65 typedef struct dirStruct_tag { |
|
66 struct _find_t file_data; |
|
67 char c_checkdrive; |
|
68 } dirStruct; |
|
69 |
|
70 typedef struct DIR_Struct { |
|
71 void * directoryPtr; |
|
72 dirStruct data; |
|
73 } DIR; |
|
74 |
|
75 #define _ST_FSTYPSZ 16 |
|
76 typedef unsigned long mode_t; |
|
77 typedef long uid_t; |
|
78 typedef long gid_t; |
|
79 typedef long off_t; |
|
80 typedef unsigned long nlink_t; |
|
81 |
|
82 typedef struct timestruc { |
|
83 time_t tv_sec; /* seconds */ |
|
84 long tv_nsec; /* and nanoseconds */ |
|
85 } timestruc_t; |
|
86 |
|
87 struct dirent { /* data from readdir() */ |
|
88 ino_t d_ino; /* inode number of entry */ |
|
89 off_t d_off; /* offset of disk direntory entry */ |
|
90 unsigned short d_reclen; /* length of this record */ |
|
91 #ifdef XP_WIN32 |
|
92 char d_name[_MAX_FNAME]; /* name of file */ |
|
93 #else |
|
94 char d_name[20]; /* name of file */ |
|
95 #endif |
|
96 }; |
|
97 |
|
98 #define S_ISDIR(s) ((s) & _S_IFDIR) |
|
99 |
|
100 #endif /* 16-bit windows */ |
|
101 |
|
102 #define CONST const |
|
103 |
|
104 #endif /* _WINDOWS */ |
|
105 |
|
106 #endif /* WINFILE_H */ |