Error handling is compatible
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
20000322-16:40 EST Paul Tucker <ptucker@sympatico.ca>
|
||||
* source/rtl/diskspac.c
|
||||
* no windows dialogs if disk not in drive.
|
||||
* Compatible error box instead.
|
||||
|
||||
2000-03-22 16:35 GMT-5 David G. Holm <dholm@jsd-llc.com>
|
||||
|
||||
* config/os2/gcc.cf
|
||||
|
||||
@@ -114,6 +114,7 @@ HB_FUNC( DISKSPACE )
|
||||
|
||||
char szPath[ 4 ];
|
||||
P_GDFSE pGetDiskFreeSpaceEx;
|
||||
UINT uiErrMode;
|
||||
|
||||
/* Get the default drive */
|
||||
|
||||
@@ -131,6 +132,10 @@ HB_FUNC( DISKSPACE )
|
||||
szPath[ 2 ] = '\\';
|
||||
szPath[ 3 ] = '\0';
|
||||
|
||||
uiErrMode = SetErrorMode( SEM_FAILCRITICALERRORS );
|
||||
|
||||
SetLastError(0);
|
||||
|
||||
pGetDiskFreeSpaceEx = ( P_GDFSE ) GetProcAddress( GetModuleHandle( "kernel32.dll" ),
|
||||
"GetDiskFreeSpaceExA");
|
||||
|
||||
@@ -208,6 +213,8 @@ HB_FUNC( DISKSPACE )
|
||||
DWORD dwNumberOfFreeClusters;
|
||||
DWORD dwTotalNumberOfClusters;
|
||||
|
||||
SetLastError(0);
|
||||
|
||||
if( GetDiskFreeSpace( szPath,
|
||||
&dwSectorsPerCluster,
|
||||
&dwBytesPerSector,
|
||||
@@ -238,6 +245,11 @@ HB_FUNC( DISKSPACE )
|
||||
( double ) dwBytesPerSector;
|
||||
}
|
||||
}
|
||||
|
||||
SetErrorMode( uiErrMode );
|
||||
|
||||
if( GetLastError() != 0 )
|
||||
hb_errRT_BASE_Ext1( EG_OPEN, 2018, NULL, NULL, 0, EF_CANDEFAULT );
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -249,4 +261,3 @@ HB_FUNC( DISKSPACE )
|
||||
|
||||
hb_retnlen( dSpace, -1, 0 );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user