Mercurial > dwindows
comparison compat.c @ 35:432c39a4ff86
New code for checking drive size on OS/2 and Windows.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 07 Sep 2001 15:27:55 +0000 |
parents | 6a246b3bb14f |
children | cddb02f847e1 |
comparison
equal
deleted
inserted
replaced
34:b03b24bb95f8 | 35:432c39a4ff86 |
---|---|
168 #endif | 168 #endif |
169 { | 169 { |
170 #if defined(__EMX__) || defined(__OS2__) | 170 #if defined(__EMX__) || defined(__OS2__) |
171 ULONG aulFSInfoBuf[40] = {0}; | 171 ULONG aulFSInfoBuf[40] = {0}; |
172 APIRET rc = NO_ERROR; | 172 APIRET rc = NO_ERROR; |
173 ULONG kbytes; | |
173 | 174 |
174 DosError(FERR_DISABLEHARDERR); | 175 DosError(FERR_DISABLEHARDERR); |
175 rc = DosQueryFSInfo(drive, | 176 rc = DosQueryFSInfo(drive, |
176 FSIL_ALLOC, | 177 FSIL_ALLOC, |
177 (PVOID)aulFSInfoBuf, | 178 (PVOID)aulFSInfoBuf, |
178 sizeof(aulFSInfoBuf)); | 179 sizeof(aulFSInfoBuf)); |
179 | 180 |
180 DosError(FERR_ENABLEHARDERR); | 181 DosError(FERR_ENABLEHARDERR); |
181 if (rc != NO_ERROR) | 182 if (rc != NO_ERROR) |
182 return 0; | 183 return 0; |
183 | 184 |
184 return (unsigned long)((aulFSInfoBuf[3] * aulFSInfoBuf[1] * (USHORT)aulFSInfoBuf[4])/1024); | 185 kbytes = aulFSInfoBuf[3]/1024; |
186 | |
187 return (unsigned long)(kbytes * aulFSInfoBuf[1] * aulFSInfoBuf[4]); | |
185 #elif defined(__WIN32__) || defined(WINNT) | 188 #elif defined(__WIN32__) || defined(WINNT) |
186 char buffer[10] = "C:\\"; | 189 char buffer[10] = "C:\\"; |
187 DWORD spc, bps, fc, tc; | 190 DWORD spc, bps, fc, tc; |
188 | 191 |
189 buffer[0] = drive + 'A' - 1; | 192 buffer[0] = drive + 'A' - 1; |
190 | 193 |
191 if(GetDiskFreeSpace(buffer, &spc, &bps, &fc, &tc) == 0) | 194 if(GetDiskFreeSpace(buffer, &spc, &bps, &fc, &tc) == 0) |
192 return 0; | 195 return 0; |
193 return (unsigned long)(spc*bps*(fc/1024)); | 196 return (unsigned long)(spc*bps*(fc/1024)); |
197 #else | |
198 return 0; | |
199 #endif | |
200 } | |
201 | |
202 /* Return in K to avoid big problems exceeding an | |
203 unsigned long when no 64bit integers are available */ | |
204 #if defined(__IBMC__) || (defined(__WIN32__) && !defined(__CYGWIN32__)) | |
205 unsigned long drivesize(int drive) | |
206 #else | |
207 unsigned long long drivesize(int drive) | |
208 #endif | |
209 { | |
210 #if defined(__EMX__) || defined(__OS2__) | |
211 ULONG aulFSInfoBuf[40] = {0}; | |
212 APIRET rc = NO_ERROR; | |
213 ULONG kbytes; | |
214 | |
215 DosError(FERR_DISABLEHARDERR); | |
216 rc = DosQueryFSInfo(drive, | |
217 FSIL_ALLOC, | |
218 (PVOID)aulFSInfoBuf, | |
219 sizeof(aulFSInfoBuf)); | |
220 | |
221 DosError(FERR_ENABLEHARDERR); | |
222 if (rc != NO_ERROR) | |
223 return 0; | |
224 | |
225 kbytes = aulFSInfoBuf[2]/1024; | |
226 | |
227 return (unsigned long)(kbytes * aulFSInfoBuf[1] * aulFSInfoBuf[4]); | |
228 #elif defined(__WIN32__) || defined(WINNT) | |
229 char buffer[10] = "C:\\"; | |
230 DWORD spc, bps, fc, tc; | |
231 | |
232 buffer[0] = drive + 'A' - 1; | |
233 | |
234 if(GetDiskFreeSpace(buffer, &spc, &bps, &fc, &tc) == 0) | |
235 return 0; | |
236 return (unsigned long)(spc*bps*(tc/1024)); | |
194 #else | 237 #else |
195 return 0; | 238 return 0; |
196 #endif | 239 #endif |
197 } | 240 } |
198 | 241 |