Mercurial > dwindows
comparison os2/dirent.c @ 525:2ff26b697877
Fixes for building with Innotek GCC. Will have to check for regressions
with VAC and EMX.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 20 Mar 2004 01:21:13 +0000 |
parents | 0e6f09149eaa |
children | e0ea29c3d1eb |
comparison
equal
deleted
inserted
replaced
524:55c9fa60af78 | 525:2ff26b697877 |
---|---|
1 #include <stdio.h> | 1 #include <stdio.h> |
2 #include <stdlib.h> | 2 #include <stdlib.h> |
3 #include <string.h> | 3 #include <string.h> |
4 #include <ctype.h> | 4 #include <ctype.h> |
5 | 5 |
6 #define INCL_DOSFILEMGR | |
7 #define INCL_DOSERRORS | |
8 #include "dw.h" | |
6 #include "platform/dirent.h" | 9 #include "platform/dirent.h" |
7 #include <errno.h> | 10 #include <errno.h> |
8 | |
9 /*#ifndef __EMX__ | |
10 #include <libx.h> | |
11 #endif */ | |
12 | |
13 #define INCL_DOSFILEMGR | |
14 #define INCL_DOSERRORS | |
15 #include <os2.h> | |
16 | 11 |
17 # define FFBUF FILEFINDBUF3 | 12 # define FFBUF FILEFINDBUF3 |
18 # define Word ULONG | 13 # define Word ULONG |
19 /* | 14 /* |
20 * LS20 recommends a request count of 100, but according to the | 15 * LS20 recommends a request count of 100, but according to the |
57 }; | 52 }; |
58 | 53 |
59 /* | 54 /* |
60 * Return first char of filesystem type, or 0 if unknown. | 55 * Return first char of filesystem type, or 0 if unknown. |
61 */ | 56 */ |
62 static char | 57 static char API getFSType(const char *path) |
63 getFSType(const char *path) | |
64 { | 58 { |
65 static char cache[1+26]; | 59 static char cache[1+26]; |
66 char drive[3], info[512]; | 60 char drive[3], info[512]; |
67 Word unit, infolen; | 61 Word unit, infolen; |
68 char r; | 62 char r; |
95 } else | 89 } else |
96 r = 0; | 90 r = 0; |
97 return cache [unit] = r; | 91 return cache [unit] = r; |
98 } | 92 } |
99 | 93 |
100 char * | 94 char * API _abs_path(const char *name, char *buffer, int len) |
101 _abs_path(const char *name, char *buffer, int len) | |
102 { | 95 { |
103 char buf[4]; | 96 char buf[4]; |
104 if (isalpha((int)name[0]) && name[1] == ':' && name[2] == '\0') { | 97 if (isalpha((int)name[0]) && name[1] == ':' && name[2] == '\0') { |
105 buf[0] = name[0]; | 98 buf[0] = name[0]; |
106 buf[1] = name[1]; | 99 buf[1] = name[1]; |
111 if (DosQueryPathInfo((PSZ)name, FIL_QUERYFULLNAME, buffer, len)) | 104 if (DosQueryPathInfo((PSZ)name, FIL_QUERYFULLNAME, buffer, len)) |
112 return NULL; | 105 return NULL; |
113 return buffer; | 106 return buffer; |
114 } | 107 } |
115 | 108 |
116 DIR * | 109 DIR * API _openxdir(const char *path, unsigned att_mask) |
117 _openxdir(const char *path, unsigned att_mask) | |
118 { | 110 { |
119 DIR *dir; | 111 DIR *dir; |
120 char name[MAXPATHLEN+3]; | 112 char name[MAXPATHLEN+3]; |
121 Word rc; | 113 Word rc; |
122 | 114 |
169 dir->next = (FFBUF *)dir->ffbuf; | 161 dir->next = (FFBUF *)dir->ffbuf; |
170 | 162 |
171 return (DIR *)dir; | 163 return (DIR *)dir; |
172 } | 164 } |
173 | 165 |
174 DIR * | 166 DIR * API _opendir(const char *pathname) |
175 _opendir(const char *pathname) | |
176 { | 167 { |
177 return openxdir(pathname, 0); | 168 return openxdir(pathname, 0); |
178 } | 169 } |
179 | 170 |
180 struct dirent * | 171 struct dirent * API _readdir(DIR *dir) |
181 _readdir(DIR *dir) | |
182 { | 172 { |
183 static int dummy_ino = 2; | 173 static int dummy_ino = 2; |
184 | 174 |
185 if (dir->index == dir->count) { | 175 if (dir->index == dir->count) { |
186 Word rc; | 176 Word rc; |
223 ++dir->index; | 213 ++dir->index; |
224 | 214 |
225 return &dir->entry; | 215 return &dir->entry; |
226 } | 216 } |
227 | 217 |
228 long | 218 long API _telldir(DIR *dir) |
229 _telldir(DIR *dir) | |
230 { | 219 { |
231 return dir->number; | 220 return dir->number; |
232 } | 221 } |
233 | 222 |
234 void | 223 void API _seekdir(DIR *dir, long off) |
235 _seekdir(DIR *dir, long off) | |
236 { | 224 { |
237 if (dir->number > off) { | 225 if (dir->number > off) { |
238 char name[MAXPATHLEN+2]; | 226 char name[MAXPATHLEN+2]; |
239 Word rc; | 227 Word rc; |
240 | 228 |
263 | 251 |
264 while (dir->number < off && readdir(dir)) | 252 while (dir->number < off && readdir(dir)) |
265 ; | 253 ; |
266 } | 254 } |
267 | 255 |
268 void | 256 void API _closedir(DIR *dir) |
269 _closedir(DIR *dir) | |
270 { | 257 { |
271 DosFindClose(dir->handle); | 258 DosFindClose(dir->handle); |
272 free(dir); | 259 free(dir); |
273 } | 260 } |
274 | 261 |