From 1c45ae7e98b56955ff71c0f7d77e36cbe31d6f90 Mon Sep 17 00:00:00 2001 From: Paul Tucker Date: Wed, 22 Mar 2000 21:38:31 +0000 Subject: [PATCH] Error handling is compatible --- harbour/ChangeLog | 5 +++++ harbour/source/rtl/diskspac.c | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9ec73ea6c1..ac39ad6759 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,8 @@ +20000322-16:40 EST Paul Tucker + * 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 * config/os2/gcc.cf diff --git a/harbour/source/rtl/diskspac.c b/harbour/source/rtl/diskspac.c index 722a7aff79..cd25ae9315 100644 --- a/harbour/source/rtl/diskspac.c +++ b/harbour/source/rtl/diskspac.c @@ -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 ); } -