comparison win/dirent.c @ 527:e0ea29c3d1eb

Fixed dw_window_pointer() so it works on Windows. Tried to fix the timer problems on Windows, but only managed to reduce the problem and eliminate obsolete timer code. Fixed a calling convention problem caused by incorrect placement of the definition of API in the compat.h header. Make dw_beep() not block on OS/2 and Windows.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 23 Mar 2004 11:00:04 +0000
parents e320dc29bfcd
children 1e3ab8adba90
comparison
equal deleted inserted replaced
526:d3ce0afa6cf5 527:e0ea29c3d1eb
3 #include <string.h> 3 #include <string.h>
4 #include <ctype.h> 4 #include <ctype.h>
5 5
6 #include <windows.h> 6 #include <windows.h>
7 7
8 #include "dirent.h" 8 #include "compat.h"
9 #include <errno.h> 9 #include <errno.h>
10 10
11 #define error(rc) errno = 255 11 #define error(rc) errno = 255
12 12
13 struct _dirdescr { 13 struct _dirdescr {
23 }; 23 };
24 24
25 /* 25 /*
26 * Return first char of filesystem type, or 0 if unknown. 26 * Return first char of filesystem type, or 0 if unknown.
27 */ 27 */
28 static char 28 static char API getFSType(const char *path)
29 getFSType(const char *path)
30 { 29 {
31 static char cache[1+26]; 30 static char cache[1+26];
32 char drive[3]; 31 char drive[3];
33 ULONG unit; 32 ULONG unit;
34 char r; 33 char r;
54 r = GetDriveType(drive); 53 r = GetDriveType(drive);
55 54
56 return cache [unit] = r; 55 return cache [unit] = r;
57 } 56 }
58 57
59 char *abs_path(const char *name, char *buffer, int len) 58 char * API abs_path(const char *name, char *buffer, int len)
60 { 59 {
61 char *buf; 60 char *buf;
62 LPTSTR file; 61 LPTSTR file;
63 62
64 if(isalpha(name[0]) && name[1] == ':' && name[2] == '\0') 63 if(isalpha(name[0]) && name[1] == ':' && name[2] == '\0')
79 if(GetFullPathName(name, len, buffer, &file)) 78 if(GetFullPathName(name, len, buffer, &file))
80 return buffer; 79 return buffer;
81 return NULL; 80 return NULL;
82 } 81 }
83 82
84 DIR *openxdir(const char *path, unsigned att_mask) 83 DIR * API openxdir(const char *path, unsigned att_mask)
85 { 84 {
86 DIR *dir; 85 DIR *dir;
87 char name[MAXPATHLEN+3]; 86 char name[MAXPATHLEN+3];
88 87
89 dir = malloc(sizeof(DIR)); 88 dir = malloc(sizeof(DIR));
125 dir->index = 0; 124 dir->index = 0;
126 125
127 return (DIR *)dir; 126 return (DIR *)dir;
128 } 127 }
129 128
130 DIR * 129 DIR * API opendir(const char *pathname)
131 opendir(const char *pathname)
132 { 130 {
133 return openxdir(pathname, 0); 131 return openxdir(pathname, 0);
134 } 132 }
135 133
136 struct dirent * 134 struct dirent * API readdir(DIR *dir)
137 readdir(DIR *dir)
138 { 135 {
139 static int dummy_ino = 2; 136 static int dummy_ino = 2;
140 137
141 if (dir->number) 138 if (dir->number)
142 { 139 {
165 dir->number++; 162 dir->number++;
166 dir->index++; 163 dir->index++;
167 return &dir->entry; 164 return &dir->entry;
168 } 165 }
169 166
170 long 167 long API telldir(DIR *dir)
171 telldir(DIR *dir)
172 { 168 {
173 return dir->number; 169 return dir->number;
174 } 170 }
175 171
176 void 172 void API seekdir(DIR *dir, long off)
177 seekdir(DIR *dir, long off)
178 { 173 {
179 if (dir->number > off) { 174 if (dir->number > off) {
180 char name[MAXPATHLEN+2]; 175 char name[MAXPATHLEN+2];
181 ULONG rc; 176 ULONG rc;
182 177
197 192
198 while (dir->number < off && readdir(dir)) 193 while (dir->number < off && readdir(dir))
199 ; 194 ;
200 } 195 }
201 196
202 void 197 void API closedir(DIR *dir)
203 closedir(DIR *dir)
204 { 198 {
205 FindClose(dir->handle); 199 FindClose(dir->handle);
206 free(dir); 200 free(dir);
207 } 201 }
208 202