Updated to cap requested type to be within allowable range

This commit is contained in:
Paul Tucker
2000-03-23 00:45:51 +00:00
parent beb3471ec8
commit eebd87c2b6
4 changed files with 33 additions and 131 deletions

View File

@@ -1,3 +1,12 @@
20000322-19:35 EST Paul Tucker <ptucker@sympatico.ca>
* include/fileio.ch
* source/rtl/dskspac.c
* Changed and reordered HB_DISK_ defines to be in the range 0-3
* source/rtl/dskspac.c
* cap uiType to HB_DISK_TOTAL for out of range types.
* doc/en/diskspac.txt
* updated
2000-03-22 17:25 GMT-5 David G. Holm <dholm@jsd-llc.com>
+ source/rtl/gtpca/kbdos2.gcc
+ Added hb_gt_ReadKey() support for os2/gcc platform

View File

@@ -26,12 +26,12 @@
* <nDrive> The number of the drive you are requesting info on where 1 = A,
* 2 = B, etc. For 0 or no parameter, DiskSpace will operate on the current
* drive. The default is 0
* <nType> The type of space being requested. The default is HB_FS_AVAIL.
* <nType> The type of space being requested. The default is HB_DISK_AVAIL.
* $RETURNS$
* <nDiskBytes> The number of bytes on the requested disk that match the
* requested type.
* $DESCRIPTION$
* By default, this function will return the number of bytes of amount of
* By default, this function will return the number of bytes of
* free space on the current drive that is available to the user
* requesting the information.
*
@@ -44,11 +44,12 @@
* will be equal to that returned for HB_FS_FREE.
* HB_FS_FREE The actual amount of free diskspace on the drive.
* HB_FS_USED The number of bytes in use on the disk.
* HB_FS_TOTAL The total size of the disk.
* HB_FS_TOTAL The total amount of space allocated for the user if
* disk quotas are in effect, otherwise, the actual size
* of the drive.
*
* If information is requested on a removeable disk that is not available,
* the O/S may request that a disk be inserted in the drive, otherwise the
* return value will be 0.
* If information is requested on a disk that is not available, a runtime
* error 2018 will be raised.
* $EXAMPLES$
* ? "You can use : " +Str( DiskSpace() ) + " bytes " +;
* "Out of a total of " + Str( DiskSpace(0,HB_FS_TOTAL) )
@@ -56,120 +57,10 @@
* R
* $COMPLIANCE$
* CA-Clipper will return an integer value which limits it's usefulness to
* drives less than 2 gigabytes. The Harbour version returns a floating
* point value with 0 decimals if the disk is > 2 gigabytes.
* drives less than 2 gigabytes. The Harbour version will return a
* floating point value with 0 decimals if the disk is > 2 gigabytes.
* <nType> is a Harbour extension.
* $SEEALSO$
* DISKFREE(),DISKUSED(),DISKFULL(),tests\tstdspac.prg
* tests\tstdspac.prg
* $END$
*/
/* $DOC$
* $FUNCNAME$
* DISKFREE()
* $CATEGORY$
* Low level disk information
* $ONELINER$
* Get the amount of space on a disk
* $SYNTAX$
* DISKFREE( [<nDrive>] ) --> nDiskbytes
* $ARGUMENTS$
* <nDrive> The number of the drive you are requesting info on where 1 = A,
* 2 = B, etc. For 0 or no parameter, DiskFree will operate on the current
* drive. The default is 0
* $RETURNS$
* <nDiskBytes> The number of bytes of space available on the requested
* disk
* $DESCRIPTION$
* This function will return the number of bytes of free space on the
* current, or requested drive.
*
* Using DiskFree(0) is the same as calling DiskSpace(0,HB_FS_FREE)
*
* If information is requested on a removeable disk that is not available,
* the O/S may request that a disk be inserted in the drive, otherwise the
* return value will be 0
* $EXAMPLES$
* ? "There is : " +Str( DiskFree() ) + " bytes " +;
* "Out of a total of " + Str( DiskSpace(0,HB_FS_TOTAL) )
* $STATUS$
* R
* $COMPLIANCE$
* - unknown -
* $SEEALSO$
* DISKSPACE(),DISKUSED(),DISKFULL(),tests\tstdspac.prg
* $END$
*/
/* $DOC$
* $FUNCNAME$
* DISKUSED()
* $CATEGORY$
* Low level disk information
* $ONELINER$
* Get the amount of space in use on a disk
* $SYNTAX$
* DISKUSED( [<nDrive>] ) --> nDiskbytes
* $ARGUMENTS$
* <nDrive> The number of the drive you are requesting info on where 1 = A,
* 2 = B, etc. For 0 or no parameter, DiskUsed will operate on the current
* drive. The default is 0
* $RETURNS$
* <nDiskBytes> The number of bytes in use on the requested disk
* $DESCRIPTION$
* This function will return the number of bytes in use on the
* current, or requested drive.
*
* Using DiskUsed(0) is the same as calling DiskSpace(0,HB_FS_USED)
*
* If information is requested on a removeable disk that is not available,
* the O/S may request that a disk be inserted in the drive, otherwise the
* return value will be 0
* $EXAMPLES$
* ? "There is : " +Str( DiskUsed() ) + " bytes " +;
* "Out of a total of " + Str( DiskSpace(0,HB_FS_USED) )
* $STATUS$
* R
* $COMPLIANCE$
* - unknown -
* $SEEALSO$
* DISKSPACE(),DISKFREE(),DISKFULL(),tests\tstdspac.prg
* $END$
*/
/* $DOC$
* $FUNCNAME$
* DISKFULL()
* $CATEGORY$
* Low level disk information
* $ONELINER$
* Get the total amount of space on a disk
* $SYNTAX$
* DISKFULL( [<nDrive>] ) --> nDiskbytes
* $ARGUMENTS$
* <nDrive> The number of the drive you are requesting info on where 1 = A,
* 2 = B, etc. For 0 or no parameter, DiskUsed will operate on the current
* drive. The default is 0
* $RETURNS$
* <nDiskBytes> The total number of bytes on the requested disk
* $DESCRIPTION$
* This function will return the number of bytes on the
* current, or requested drive.
*
* Using DiskFull(0) is the same as calling DiskSpace(0,HB_FS_TOTAL)
*
* If information is requested on a removeable disk that is not available,
* the O/S may request that a disk be inserted in the drive, otherwise the
* return value will be 0
* $EXAMPLES$
* ? "There is : " +Str( DiskUsed() ) + " bytes " +;
* "Out of a total of " + Str( DiskFull() )
* $STATUS$
* R
* $COMPLIANCE$
* - unknown -
* $SEEALSO$
* DISKSPACE(),DISKFREE(),DISKUSED(),tests\tstdspac.prg
* $END$
*/

View File

@@ -86,10 +86,10 @@
#define F_ERROR ( -1 ) /* Unspecified error */
/* DISKSPACE() types */
#define HB_DISK_AVAIL 0
#define HB_DISK_FREE 1
#define HB_DISK_AVAIL 2
#define HB_DISK_TOTAL 4
#define HB_DISK_USED 8
#define HB_DISK_USED 2
#define HB_DISK_TOTAL 3
#endif /* _FILEIO_CH */

View File

@@ -67,6 +67,8 @@ HB_FUNC( DISKSPACE )
USHORT uiType = ISNUM( 2 ) ? hb_parni( 2 ) : HB_DISK_AVAIL;
double dSpace = 0.0;
uiType = min( uiType, HB_DISK_TOTAL );
#if defined(HB_OS_DOS) || defined(__WATCOMC__)
struct diskfree_t disk;
@@ -84,15 +86,15 @@ HB_FUNC( DISKSPACE )
{
switch( uiType )
{
case HB_DISK_FREE:
case HB_DISK_AVAIL:
case HB_DISK_FREE:
dSpace = ( double ) disk.avail_clusters *
( double ) disk.sectors_per_cluster *
( double ) disk.bytes_per_sector;
break;
case HB_DISK_TOTAL:
case HB_DISK_USED:
case HB_DISK_TOTAL:
dSpace = ( double ) disk.total_clusters *
( double ) disk.sectors_per_cluster *
( double ) disk.bytes_per_sector );
@@ -153,16 +155,16 @@ HB_FUNC( DISKSPACE )
{
switch( uiType )
{
case HB_DISK_FREE:
memcpy( &i64RetVal, &i64FreeBytes, sizeof( ULARGE_INTEGER ) );
break;
case HB_DISK_AVAIL:
memcpy( &i64RetVal, &i64FreeBytesToCaller, sizeof( ULARGE_INTEGER ) );
break;
case HB_DISK_TOTAL:
case HB_DISK_FREE:
memcpy( &i64RetVal, &i64FreeBytes, sizeof( ULARGE_INTEGER ) );
break;
case HB_DISK_USED:
case HB_DISK_TOTAL:
memcpy( &i64RetVal, &i64TotalBytes, sizeof( ULARGE_INTEGER ) );
}
@@ -220,15 +222,15 @@ HB_FUNC( DISKSPACE )
{
switch( uiType )
{
case HB_DISK_FREE:
case HB_DISK_AVAIL:
case HB_DISK_FREE:
dSpace = ( double ) dwNumberOfFreeClusters *
( double ) dwSectorsPerCluster *
( double ) dwBytesPerSector;
break;
case HB_DISK_TOTAL:
case HB_DISK_USED:
case HB_DISK_TOTAL:
dSpace = ( double ) dwTotalNumberOfClusters *
( double ) dwSectorsPerCluster *
( double ) dwBytesPerSector;