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