2011-12-30 13:15 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* harbour/ChangeLog
    ! fixed typo in file name in my previous commit.
      It should be gtwvg.c not gtwvg.h

  * harbour/src/rtl/disksphb.c
    ! fixed variable declaration for strict ANSI C compilers
This commit is contained in:
Przemyslaw Czerpak
2011-12-30 12:15:50 +00:00
parent 0bca1bc173
commit 2421162fb1
2 changed files with 137 additions and 123 deletions

View File

@@ -16,6 +16,14 @@
The license applies to all entries newer than 2009-04-28.
*/
2011-12-30 13:15 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* harbour/ChangeLog
! fixed typo in file name in my previous commit.
It should be gtwvg.c not gtwvg.h
* harbour/src/rtl/disksphb.c
! fixed variable declaration for strict ANSI C compilers
2011-12-29 23:51 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* harbour/include/hbapistr.h
* harbour/src/vm/strapi.c
@@ -40,7 +48,7 @@
! added missing 'void * hText' member to HB_GOBJS struct
! changed 'LPTSTR lpText' to 'LPCTSTR lpText' in HB_GOBJS struct
* harbour/contrib/gtwvg/gtwvg.h
* harbour/contrib/gtwvg/gtwvg.c
! fixed old code not updated to follow recent Pritpal modifications
* harbour/contrib/hbzebra/qrcode.c

View File

@@ -89,24 +89,6 @@ HB_FUNC( HB_DISKSPACE )
#if defined( HB_OS_WIN )
{
#if defined( _MSC_VER ) || defined( __LCC__ ) || \
( defined( __GNUC__ ) && !defined( __RSXNT__ ) )
# define HB_GET_LARGE_UINT( v ) ( ( double ) (v).LowPart + \
( double ) (v).HighPart * \
( ( ( double ) 0xFFFFFFFF ) + 1 ) )
#else
/* NOTE: Borland doesn't seem to deal with the un-named
struct that is part of ULARGE_INTEGER
[pt] */
# define HB_GET_LARGE_UINT( v ) ( ( double ) (v).u.LowPart + \
( double ) (v).u.HighPart * \
( ( ( double ) 0xFFFFFFFF ) + 1 ) )
#endif
ULARGE_INTEGER i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes;
UINT uiErrMode = SetErrorMode( SEM_FAILCRITICALERRORS );
HB_BOOL fResult;
void * hPath;
LPCTSTR lpPath = HB_PARSTR( 1, &hPath, NULL );
TCHAR szPathBuf[ 4 ];
@@ -130,101 +112,123 @@ HB_FUNC( HB_DISKSPACE )
lpPath = szPathBuf;
}
{
UINT uiErrMode = SetErrorMode( SEM_FAILCRITICALERRORS );
HB_BOOL fResult;
#if !defined( HB_OS_WIN_CE ) && !defined( HB_OS_WIN_64 )
/* NOTE: We need to call this function dynamically to maintain support
Win95 first edition. It was introduced in Win95B (aka OSR2) [vszakats] */
typedef BOOL ( WINAPI * P_GDFSE )( LPCTSTR, PULARGE_INTEGER,
PULARGE_INTEGER, PULARGE_INTEGER );
static P_GDFSE s_pGetDiskFreeSpaceEx = NULL;
static HB_BOOL s_fInit = HB_FALSE;
/* NOTE: We need to call this function dynamically to maintain support
Win95 first edition. It was introduced in Win95B (aka OSR2) [vszakats] */
typedef BOOL ( WINAPI * P_GDFSE )( LPCTSTR, PULARGE_INTEGER,
PULARGE_INTEGER, PULARGE_INTEGER );
static P_GDFSE s_pGetDiskFreeSpaceEx = NULL;
static HB_BOOL s_fInit = HB_FALSE;
if( ! s_fInit )
{
s_pGetDiskFreeSpaceEx = ( P_GDFSE )
#if defined( UNICODE )
GetProcAddress( GetModuleHandle( hb_iswin9x() ? TEXT( "unicows.dll" ) : TEXT( "kernel32.dll" ) ),
"GetDiskFreeSpaceExW" );
#else
GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
"GetDiskFreeSpaceExA" );
#endif
s_fInit = HB_TRUE;
}
if( !s_pGetDiskFreeSpaceEx )
{
DWORD dwSectorsPerCluster;
DWORD dwBytesPerSector;
DWORD dwNumberOfFreeClusters;
DWORD dwTotalNumberOfClusters;
fResult = GetDiskFreeSpace( lpPath,
&dwSectorsPerCluster,
&dwBytesPerSector,
&dwNumberOfFreeClusters,
&dwTotalNumberOfClusters ) ? HB_TRUE : HB_FALSE;
hb_fsSetIOError( fResult, 0 );
if( fResult )
if( ! s_fInit )
{
switch( uiType )
s_pGetDiskFreeSpaceEx = ( P_GDFSE )
#if defined( UNICODE )
GetProcAddress( GetModuleHandle( hb_iswin9x() ? TEXT( "unicows.dll" ) : TEXT( "kernel32.dll" ) ),
"GetDiskFreeSpaceExW" );
#else
GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
"GetDiskFreeSpaceExA" );
#endif
s_fInit = HB_TRUE;
}
if( !s_pGetDiskFreeSpaceEx )
{
DWORD dwSectorsPerCluster;
DWORD dwBytesPerSector;
DWORD dwNumberOfFreeClusters;
DWORD dwTotalNumberOfClusters;
fResult = GetDiskFreeSpace( lpPath,
&dwSectorsPerCluster,
&dwBytesPerSector,
&dwNumberOfFreeClusters,
&dwTotalNumberOfClusters ) ? HB_TRUE : HB_FALSE;
hb_fsSetIOError( fResult, 0 );
if( fResult )
{
case HB_DISK_AVAIL:
case HB_DISK_FREE:
dSpace = ( double ) dwNumberOfFreeClusters *
( double ) dwSectorsPerCluster *
( double ) dwBytesPerSector;
break;
switch( uiType )
{
case HB_DISK_AVAIL:
case HB_DISK_FREE:
dSpace = ( double ) dwNumberOfFreeClusters *
( double ) dwSectorsPerCluster *
( double ) dwBytesPerSector;
break;
case HB_DISK_USED:
case HB_DISK_TOTAL:
dSpace = ( double ) dwTotalNumberOfClusters *
( double ) dwSectorsPerCluster *
( double ) dwBytesPerSector;
if( uiType == HB_DISK_USED )
dSpace -= ( double ) dwNumberOfFreeClusters *
case HB_DISK_USED:
case HB_DISK_TOTAL:
dSpace = ( double ) dwTotalNumberOfClusters *
( double ) dwSectorsPerCluster *
( double ) dwBytesPerSector;
break;
if( uiType == HB_DISK_USED )
dSpace -= ( double ) dwNumberOfFreeClusters *
( double ) dwSectorsPerCluster *
( double ) dwBytesPerSector;
break;
}
}
}
}
else
else
#endif
{
fResult = GetDiskFreeSpaceEx( lpPath,
( PULARGE_INTEGER ) &i64FreeBytesToCaller,
( PULARGE_INTEGER ) &i64TotalBytes,
( PULARGE_INTEGER ) &i64FreeBytes );
hb_fsSetIOError( fResult, 0 );
if( fResult )
{
switch( uiType )
#if defined( _MSC_VER ) || defined( __LCC__ ) || \
( defined( __GNUC__ ) && !defined( __RSXNT__ ) )
# define HB_GET_LARGE_UINT( v ) ( ( double ) (v).LowPart + \
( double ) (v).HighPart * \
( ( ( double ) 0xFFFFFFFF ) + 1 ) )
#else
/* NOTE: Borland doesn't seem to deal with the un-named
struct that is part of ULARGE_INTEGER
[pt] */
# define HB_GET_LARGE_UINT( v ) ( ( double ) (v).u.LowPart + \
( double ) (v).u.HighPart * \
( ( ( double ) 0xFFFFFFFF ) + 1 ) )
#endif
ULARGE_INTEGER i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes;
fResult = GetDiskFreeSpaceEx( lpPath,
( PULARGE_INTEGER ) &i64FreeBytesToCaller,
( PULARGE_INTEGER ) &i64TotalBytes,
( PULARGE_INTEGER ) &i64FreeBytes );
hb_fsSetIOError( fResult, 0 );
if( fResult )
{
case HB_DISK_AVAIL:
dSpace = HB_GET_LARGE_UINT( i64FreeBytesToCaller );
break;
switch( uiType )
{
case HB_DISK_AVAIL:
dSpace = HB_GET_LARGE_UINT( i64FreeBytesToCaller );
break;
case HB_DISK_FREE:
dSpace = HB_GET_LARGE_UINT( i64FreeBytes );
break;
case HB_DISK_FREE:
dSpace = HB_GET_LARGE_UINT( i64FreeBytes );
break;
case HB_DISK_TOTAL:
dSpace = HB_GET_LARGE_UINT( i64TotalBytes );
break;
case HB_DISK_TOTAL:
dSpace = HB_GET_LARGE_UINT( i64TotalBytes );
break;
case HB_DISK_USED:
dSpace = HB_GET_LARGE_UINT( i64TotalBytes ) -
HB_GET_LARGE_UINT( i64FreeBytes );
break;
case HB_DISK_USED:
dSpace = HB_GET_LARGE_UINT( i64TotalBytes ) -
HB_GET_LARGE_UINT( i64FreeBytes );
break;
}
}
}
SetErrorMode( uiErrMode );
}
hb_strfree( hPath );
SetErrorMode( uiErrMode );
}
#elif defined( HB_OS_DOS ) || defined( HB_OS_OS2 )
{
@@ -288,39 +292,41 @@ HB_FUNC( HB_DISKSPACE )
break;
}
#else /* HB_OS_OS2 */
struct _FSALLOCATE fsa;
USHORT rc;
/* Query level 1 info from filesystem */
while( ( rc = DosQueryFSInfo( uiDrive, 1, &fsa, sizeof( fsa ) ) ) != 0 )
{
if( hb_errRT_BASE_Ext1( EG_OPEN, 2018, NULL, NULL, 0, (EF_CANDEFAULT | EF_CANRETRY), HB_ERR_ARGS_BASEPARAMS ) != E_RETRY )
break;
}
hb_fsSetIOError( rc == 0, 0 );
if( rc == 0 )
{
switch( uiType )
struct _FSALLOCATE fsa;
USHORT rc;
/* Query level 1 info from filesystem */
while( ( rc = DosQueryFSInfo( uiDrive, 1, &fsa, sizeof( fsa ) ) ) != 0 )
{
case HB_DISK_AVAIL:
case HB_DISK_FREE:
dSpace = ( double ) fsa.cUnitAvail *
( double ) fsa.cSectorUnit *
( double ) fsa.cbSector;
if( hb_errRT_BASE_Ext1( EG_OPEN, 2018, NULL, NULL, 0, (EF_CANDEFAULT | EF_CANRETRY), HB_ERR_ARGS_BASEPARAMS ) != E_RETRY )
break;
}
case HB_DISK_USED:
case HB_DISK_TOTAL:
dSpace = ( double ) fsa.cUnit *
( double ) fsa.cSectorUnit *
( double ) fsa.cbSector;
hb_fsSetIOError( rc == 0, 0 );
if( uiType == HB_DISK_USED )
dSpace -= ( double ) fsa.cUnitAvail *
( double ) fsa.cSectorUnit *
( double ) fsa.cbSector;
break;
if( rc == 0 )
{
switch( uiType )
{
case HB_DISK_AVAIL:
case HB_DISK_FREE:
dSpace = ( double ) fsa.cUnitAvail *
( double ) fsa.cSectorUnit *
( double ) fsa.cbSector;
break;
case HB_DISK_USED:
case HB_DISK_TOTAL:
dSpace = ( double ) fsa.cUnit *
( double ) fsa.cSectorUnit *
( double ) fsa.cbSector;
if( uiType == HB_DISK_USED )
dSpace -= ( double ) fsa.cUnitAvail *
( double ) fsa.cSectorUnit *
( double ) fsa.cbSector;
break;
}
}
}
#endif