# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 999876475 0 # Node ID 432c39a4ff86f57c139cce54e7339d45505f5b29 # Parent b03b24bb95f85fae9c54ab55a0413b4b009c86eb New code for checking drive size on OS/2 and Windows. diff -r b03b24bb95f8 -r 432c39a4ff86 compat.c --- a/compat.c Mon Sep 03 23:30:43 2001 +0000 +++ b/compat.c Fri Sep 07 15:27:55 2001 +0000 @@ -170,18 +170,21 @@ #if defined(__EMX__) || defined(__OS2__) ULONG aulFSInfoBuf[40] = {0}; APIRET rc = NO_ERROR; + ULONG kbytes; DosError(FERR_DISABLEHARDERR); rc = DosQueryFSInfo(drive, - FSIL_ALLOC, - (PVOID)aulFSInfoBuf, - sizeof(aulFSInfoBuf)); + FSIL_ALLOC, + (PVOID)aulFSInfoBuf, + sizeof(aulFSInfoBuf)); DosError(FERR_ENABLEHARDERR); if (rc != NO_ERROR) return 0; - return (unsigned long)((aulFSInfoBuf[3] * aulFSInfoBuf[1] * (USHORT)aulFSInfoBuf[4])/1024); + kbytes = aulFSInfoBuf[3]/1024; + + return (unsigned long)(kbytes * aulFSInfoBuf[1] * aulFSInfoBuf[4]); #elif defined(__WIN32__) || defined(WINNT) char buffer[10] = "C:\\"; DWORD spc, bps, fc, tc; @@ -196,6 +199,46 @@ #endif } +/* Return in K to avoid big problems exceeding an + unsigned long when no 64bit integers are available */ +#if defined(__IBMC__) || (defined(__WIN32__) && !defined(__CYGWIN32__)) +unsigned long drivesize(int drive) +#else +unsigned long long drivesize(int drive) +#endif +{ +#if defined(__EMX__) || defined(__OS2__) + ULONG aulFSInfoBuf[40] = {0}; + APIRET rc = NO_ERROR; + ULONG kbytes; + + DosError(FERR_DISABLEHARDERR); + rc = DosQueryFSInfo(drive, + FSIL_ALLOC, + (PVOID)aulFSInfoBuf, + sizeof(aulFSInfoBuf)); + + DosError(FERR_ENABLEHARDERR); + if (rc != NO_ERROR) + return 0; + + kbytes = aulFSInfoBuf[2]/1024; + + return (unsigned long)(kbytes * aulFSInfoBuf[1] * aulFSInfoBuf[4]); +#elif defined(__WIN32__) || defined(WINNT) + char buffer[10] = "C:\\"; + DWORD spc, bps, fc, tc; + + buffer[0] = drive + 'A' - 1; + + if(GetDiskFreeSpace(buffer, &spc, &bps, &fc, &tc) == 0) + return 0; + return (unsigned long)(spc*bps*(tc/1024)); +#else + return 0; +#endif +} + int isdrive(int drive) { #if defined(__EMX__) || defined(__OS2__) diff -r b03b24bb95f8 -r 432c39a4ff86 dwcompat.def --- a/dwcompat.def Mon Sep 03 23:30:43 2001 +0000 +++ b/dwcompat.def Fri Sep 07 15:27:55 2001 +0000 @@ -21,6 +21,7 @@ setfileinfo @22 drivefree @23 isdrive @24 + drivesize @25 opendir @30 openxdir @31 diff -r b03b24bb95f8 -r 432c39a4ff86 dwcompatw.def --- a/dwcompatw.def Mon Sep 03 23:30:43 2001 +0000 +++ b/dwcompatw.def Fri Sep 07 15:27:55 2001 +0000 @@ -16,6 +16,7 @@ setfileinfo @22 drivefree @23 isdrive @24 + drivesize @25 opendir @30 openxdir @31