diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 843ee16d00..f7f6b49911 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,18 @@ +20000322-02:25 GMT+1 Victor Szakats + * include/fileio.ch + include/hbapi.h + include/hbapifs.h + source/rtl/diskspac.c + source/tools/io.c + * hb_DiskSpace() renamed to hb_fsDiskSpace() and moved the FS API header. + * HB_DISK_* constants moved to fileio.ch + + Added a new parameter to the Harbour level DISKSPACE() function to + enable access to the new features. This is a Harbour extenstion. + ! DISKSPACE() (and the IO.C versions) use hb_retnlen() instead of + hb_retnd(). + ! CD(), RD(), MD() are now using the FS API, so they are now working + on more platforms. + 20000321-19:58 EST Paul Tucker * source/rtl/diskspac.c * Borland does not see the unnamed struct that is part of ULARGE_INT. @@ -23,7 +38,7 @@ * DiskSpace() calls hb_diskSpace() * source/tools/io.c * DiskFree(), DiskUsed, DiskFull() now call hb_DiskSpace() - * include/hbapi.c + * include/hbapi.h + #define HB_DISK_.... + declaration for hb_DiskSpace() ! Disk...() functions return a double. @@ -208,7 +223,8 @@ source/rtl/stuff.c source/rtl/word.c - Superfluous #includes removed. -20000320-23:00 GMT-3 Luiz Rafael Culik + +20000320-23:00 GMT-3 Luiz Rafael Culik samples/cccppc/*.* ! Removed contents from the CCCPPC dir diff --git a/harbour/include/extend.api b/harbour/include/extend.api index 48a811c2d3..d29630d79e 100644 --- a/harbour/include/extend.api +++ b/harbour/include/extend.api @@ -43,7 +43,7 @@ typedef PHB_ITEM ITEM; #ifndef CLIPPERDEFS -typedef double XDOUBLE; + typedef double XDOUBLE; #endif /* Compatible defines */ @@ -56,6 +56,8 @@ typedef double XDOUBLE; #define ALIAS IT_ALIAS #define MPTR IT_BYREF /* or'ed with type when passed by reference */ #define MEMO IT_MEMO +/* NOTE: CA-Cl*pper bug: WORD will conflict with the typedef with the same + name in clipdefs.h [vszakats] */ #define WORD ( IT_INTEGER | IT_LONG ) #define ARRAY IT_ARRAY #define BLOCK IT_BLOCK @@ -92,3 +94,4 @@ typedef double XDOUBLE; #define _stornl hb_stornl #endif /* _EXTEND_API */ + diff --git a/harbour/include/fileio.ch b/harbour/include/fileio.ch index 944c8b2a05..813ed6d2b8 100644 --- a/harbour/include/fileio.ch +++ b/harbour/include/fileio.ch @@ -85,4 +85,11 @@ /* File system error codes */ #define F_ERROR ( -1 ) /* Unspecified error */ +/* DISKSPACE() types */ +#define HB_DISK_FREE 1 +#define HB_DISK_AVAIL 2 +#define HB_DISK_TOTAL 4 +#define HB_DISK_USED 8 + #endif /* _FILEIO_CH */ + diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index 433cb66d94..19a3df3b46 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -97,13 +97,6 @@ #define PCOUNT hb_pcount() #define ALENGTH( n ) hb_parinfa( n, 0 ) -/* used by DiskSpace(), etc. */ -#define HB_DISK_FREE 1 -#define HB_DISK_AVAIL 2 -#define HB_DISK_TOTAL 4 -#define HB_DISK_USED 8 -extern double hb_DiskSpace( USHORT, USHORT ); - /* forward declarations */ struct _HB_CODEBLOCK; struct _HB_BASEARRAY; diff --git a/harbour/include/hbapifs.h b/harbour/include/hbapifs.h index 4d9d7a231a..a5ac138bce 100644 --- a/harbour/include/hbapifs.h +++ b/harbour/include/hbapifs.h @@ -86,6 +86,7 @@ extern BYTE * hb_fsCurDir ( USHORT uiDrive ); extern USHORT hb_fsCurDirBuff ( USHORT uiDrive, BYTE * pbyBuffer, ULONG ulLen ); extern BYTE hb_fsCurDrv ( void ); extern int hb_fsDelete ( BYTE * pszFileName ); +extern double hb_fsDiskSpace ( USHORT uiDrive, USHORT uiType ); extern USHORT hb_fsError ( void ); extern BOOL hb_fsFile ( BYTE * pszFileName ); extern ULONG hb_fsFSize ( BYTE * pszFileName, BOOL bUseDirEntry ); diff --git a/harbour/source/rtl/diskspac.c b/harbour/source/rtl/diskspac.c index c565edd234..4f8448645f 100644 --- a/harbour/source/rtl/diskspac.c +++ b/harbour/source/rtl/diskspac.c @@ -58,7 +58,7 @@ #include #endif -double hb_DiskSpace( USHORT uiDrive, USHORT uiType ) +double hb_fsDiskSpace( USHORT uiDrive, USHORT uiType ) { double dSpace = 0.0; @@ -93,6 +93,7 @@ double hb_DiskSpace( USHORT uiDrive, USHORT uiType ) ( double ) disk.bytes_per_sector ); break; } + if( uiType == HB_DISK_USED ) dSpace -= ( double ) disk.avail_clusters * ( double ) disk.sectors_per_cluster * @@ -157,15 +158,15 @@ double hb_DiskSpace( USHORT uiDrive, USHORT uiType ) dSpace = ( double ) i64RetVal.u.HighPart + ( double ) i64RetVal.u.HighPart * - ( double ) 0xffffffff ; - dSpace += ( double ) i64RetVal.u.LowPart ; + ( double ) 0xFFFFFFFF; + dSpace += ( double ) i64RetVal.u.LowPart; if( uiType == HB_DISK_USED ) { dSpace -= ( double ) i64FreeBytes.u.HighPart + ( double ) i64FreeBytes.u.HighPart * - ( double ) 0xffffffff ; - dSpace -= ( double ) i64FreeBytes.u.LowPart ; + ( double ) 0xFFFFFFFF; + dSpace -= ( double ) i64FreeBytes.u.LowPart; } } } @@ -218,8 +219,12 @@ double hb_DiskSpace( USHORT uiDrive, USHORT uiType ) return dSpace; } +/* NOTE: The second parameter is a Harbour extension, check fileio.ch for + the possible values. */ HB_FUNC( DISKSPACE ) { - hb_retnd( hb_DiskSpace( ISNUM( 1 ) ? hb_parni( 1 ) : 0, HB_DISK_AVAIL )); + hb_retnlen( hb_fsDiskSpace( ISNUM( 1 ) ? hb_parni( 1 ) : 0, + ISNUM( 2 ) ? hb_parni( 2 ) : HB_DISK_AVAIL ), -1, 0 ); } + diff --git a/harbour/source/tools/io.c b/harbour/source/tools/io.c index 80a77d3e24..cbe4624f4b 100644 --- a/harbour/source/tools/io.c +++ b/harbour/source/tools/io.c @@ -3,53 +3,35 @@ */ #include "hbapi.h" - -#if defined(HB_OS_DOS) - #include - #include - #include -#endif +#include "hbapifs.h" HB_FUNC( CD ) { -#if defined(HB_OS_DOS) - hb_retni( ISCHAR( 1 ) ? chdir( hb_parc( 1 ) ) : 0 ); -#else - hb_retni( 0 ); -#endif + hb_retni( ISCHAR( 1 ) ? hb_fsChDir( ( BYTE * ) hb_parc( 1 ) ) : 0 ); } HB_FUNC( MD ) { -#if defined(HB_OS_DOS) - hb_retni( ISCHAR( 1 ) ? mkdir( hb_parc( 1 ) ) : 0 ); -#else - hb_retni( 0 ); -#endif + hb_retni( ISCHAR( 1 ) ? hb_fsMkDir( ( BYTE * ) hb_parc( 1 ) ) : 0 ); } HB_FUNC( RD ) { -#if defined(HB_OS_DOS) - hb_retni( ISCHAR( 1 ) ? rmdir( hb_parc( 1 ) ) : 0 ); -#else - hb_retni( 0 ); -#endif + hb_retni( ISCHAR( 1 ) ? hb_fsRmDir( ( BYTE * ) hb_parc( 1 ) ) : 0 ); } HB_FUNC( DISKUSED ) { - hb_retnd( hb_DiskSpace( ISNUM( 1 ) ? hb_parni( 1 ) : 0, HB_DISK_USED )); + hb_retnlen( hb_fsDiskSpace( ISNUM( 1 ) ? hb_parni( 1 ) : 0, HB_DISK_USED ), -1, 0 ); } - HB_FUNC( DISKFREE ) { - hb_retnd( hb_DiskSpace( ISNUM( 1 ) ? hb_parni( 1 ) : 0, HB_DISK_FREE )); + hb_retnlen( hb_fsDiskSpace( ISNUM( 1 ) ? hb_parni( 1 ) : 0, HB_DISK_FREE ), -1, 0 ); } - HB_FUNC( DISKFULL ) { - hb_retnd( hb_DiskSpace( ISNUM( 1 ) ? hb_parni( 1 ) : 0, HB_DISK_TOTAL )); + hb_retnlen( hb_fsDiskSpace( ISNUM( 1 ) ? hb_parni( 1 ) : 0, HB_DISK_TOTAL ), -1, 0 ); } +