From 823f2a484a5d668e0fb342e57f24266a13ff6004 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 12 Oct 1999 00:41:35 +0000 Subject: [PATCH] 19991012-02:30 GMT+1 --- harbour/ChangeLog | 17 +++++++++ harbour/include/caundoc.api | Bin 2217 -> 2596 bytes harbour/include/ctoharb.h | 31 --------------- harbour/include/filesys.h | 3 ++ harbour/source/rtl/filesys.c | 72 +++++++++++++++++++++++------------ harbour/source/vm/hvm.c | 2 +- 6 files changed, 69 insertions(+), 56 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9becfea596..c8f31872f3 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,20 @@ +19991012-02:30 GMT+1 Victor Szel + * source/rtl/filesys.c + + Added some info about driver numbering to hb_fsChDrv(), hb_fsIsDrv(), + hb_fsCurDrv(), hb_fsCurDir() + + hb_fsIsDevice() added. (by Jose Lalin), return value type changed to + BOOL to match Clipper. + ! hb_fsIsDrv(), hb_fsChDrv() fixed to call the OS functions with the + right drive number. (Please test this!) + * include/ctoharb.h + + More undocumented file functions added. (by Jose Lalin) + * include/filesys.h + ! Missing hb_fsSetDev*() prototypes added. + * include/ctoharb.h + ! Double copyright header fixed. + * source/vm/hvm.c + % w += 1 -> w++ + 19991011-23:54 GMT+1 Victor Szel * source/rtl/fm.c + Newline readded to the closing //INFO message ;) diff --git a/harbour/include/caundoc.api b/harbour/include/caundoc.api index ce7d39a855c8b2ca7ea50eae85f4ffb8fc71b0ac..d0d4dba2e9da26db09ad89bc79f0f69a26e81e7a 100644 GIT binary patch delta 430 zcmZ1}xI|>bW;UCQl*}Rp7|2M9Pb+rLaLFuU;8IRWP0P$nRfsQ1&PXXLgDFvfsVORB zm@LSy%*ZhLA-f8YT+XIakD{xz2+3%OuF@iOqk)PLX2TT$%|^06CAF+5u^i?Au%h79 z5|`Anpu}=yb*afkMfqr+aRmt>E6OYe8kd=z3Na3Bm}fE2ET9mYGK9Mzeg-N7`FTIP z641Am>`JQ0>T|P^JPT3pn+@{ppIN_3ezxf__A^= F0RUP+ezpJr delta 51 zcmZ1?vQluvX12*L>=KjBIaMaF;82?Uo=ti3X&@cLsXRFmNWbGynQRB7h1pdmH*hWi E0LD%b(*OVf diff --git a/harbour/include/ctoharb.h b/harbour/include/ctoharb.h index 6097654e4c..c4a140aa56 100644 --- a/harbour/include/ctoharb.h +++ b/harbour/include/ctoharb.h @@ -33,37 +33,6 @@ * */ -/* - Harbour Project source code - - Harbour from C caller functions - - Copyright 1999 Antonio Linares - www - http://www.harbour-project.org - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version, with one exception: - - The exception is that if you link the Harbour Runtime Library (HRL) - and/or the Harbour Virtual Machine (HVM) with other files to produce - an executable, this does not by itself cause the resulting executable - to be covered by the GNU General Public License. Your use of that - executable is in no way restricted on account of linking the HRL - and/or HVM code into it. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit - their web site at http://www.gnu.org/). -*/ - #ifndef HB_CTOHARB_H_ #define HB_CTOHARB_H_ diff --git a/harbour/include/filesys.h b/harbour/include/filesys.h index a443f09006..725db85b36 100644 --- a/harbour/include/filesys.h +++ b/harbour/include/filesys.h @@ -94,6 +94,7 @@ extern BOOL hb_fsFile ( BYTE * pFilename ); extern FHANDLE hb_fsExtOpen ( BYTE * pFilename, BYTE * pDefExt, USHORT uiFlags, BYTE * pPaths, PHB_ITEM pError ); extern USHORT hb_fsIsDrv ( BYTE nDrive ); +extern BOOL hb_fsIsDevice ( FHANDLE hFileHandle ); extern BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart, ULONG ulLength, USHORT uiMode ); extern BOOL hb_fsMkDir ( BYTE * pDirName ); @@ -104,6 +105,8 @@ extern int hb_fsRename ( BYTE * pOldName, BYTE * pNewName ); extern ULONG hb_fsSeek ( FHANDLE hFileHandle, LONG lOffset, USHORT uiMode ); extern ULONG hb_fsTell ( FHANDLE hFileHandle ); extern void hb_fsSetDevMode ( FHANDLE hFileHandle, USHORT uiDevMode ); +extern void hb_fsSetDevRaw ( FHANDLE hFileHandle ); +extern void hb_fsSetDevText ( FHANDLE hFileHandle ); extern void hb_fsSetError ( USHORT uiError ); extern USHORT hb_fsWrite ( FHANDLE hFileHandle, BYTE * pBuff, USHORT ulCount ); diff --git a/harbour/source/rtl/filesys.c b/harbour/source/rtl/filesys.c index df507fc81d..0ad2b00f6e 100644 --- a/harbour/source/rtl/filesys.c +++ b/harbour/source/rtl/filesys.c @@ -57,6 +57,7 @@ * hb_fsChDrv() * hb_fsCurDrv() * hb_fsIsDrv() + * hb_fsIsDevice() * * See doc/license.txt for licensing terms. * @@ -475,6 +476,16 @@ void hb_fsSetDevMode( FHANDLE hFileHandle, USHORT uiDevMode ) } +void hb_fsSetDevRaw( FHANDLE hFileHandle ) +{ + hb_fsSetDevMode( hFileHandle, FD_BINARY ); +} + +void hb_fsSetDevText( FHANDLE hFileHandle ) +{ + hb_fsSetDevMode( hFileHandle, FD_TEXT ); +} + USHORT hb_fsRead( FHANDLE hFileHandle, BYTE * pBuff, USHORT uiCount ) { USHORT uiRead; @@ -894,6 +905,7 @@ BOOL hb_fsRmDir( BYTE * pDirname ) } /* TODO: Make it thread safe */ +/* NOTE: 0 = current drive, 1 = A, 2 = B, 3 = C, etc. */ BYTE * hb_fsCurDir( USHORT uiDrive ) { @@ -917,8 +929,8 @@ BYTE * hb_fsCurDir( USHORT uiDrive ) return ( BYTE * ) cwd_buff; } -/* TODO: add documentation - */ +/* NOTE: 0=A:, 1=B:, 2=C:, 3=D:, ... */ +/* TODO: add documentation */ USHORT hb_fsChDrv( BYTE nDrive ) { @@ -929,8 +941,8 @@ USHORT hb_fsChDrv( BYTE nDrive ) USHORT uiSave = _getdrive(); errno = 0; - _chdrive( nDrive ); - if( nDrive == _getdrive() ) + _chdrive( nDrive + 1 ); + if( ( nDrive + 1 ) == _getdrive() ) { uiResult = 0; s_uiErrorLast = errno; @@ -952,9 +964,9 @@ USHORT hb_fsChDrv( BYTE nDrive ) */ _dos_getdrive( &uiSave ); - _dos_setdrive( nDrive, &uiTotal ); + _dos_setdrive( nDrive + 1, &uiTotal ); _dos_getdrive( &uiTotal ); - if( nDrive == uiTotal ) + if( ( nDrive + 1 ) == uiTotal ) { uiResult = 0; s_uiErrorLast = 0; @@ -976,6 +988,9 @@ USHORT hb_fsChDrv( BYTE nDrive ) return uiResult; } +/* NOTE: 0=A:, 1=B:, 2=C:, 3=D:, ... */ +/* TODO: add documentation */ + USHORT hb_fsIsDrv( BYTE nDrive ) { USHORT uiResult; @@ -985,8 +1000,8 @@ USHORT hb_fsIsDrv( BYTE nDrive ) USHORT uiSave = _getdrive(); errno = 0; - _chdrive( nDrive ); - if( nDrive == _getdrive() ) + _chdrive( nDrive + 1 ); + if( ( nDrive + 1 ) == _getdrive() ) { uiResult = 0; s_uiErrorLast = errno; @@ -1011,9 +1026,9 @@ USHORT hb_fsIsDrv( BYTE nDrive ) s_uiErrorLast = 0; uiResult = 0; - _dos_setdrive( nDrive, &uiTotal ); + _dos_setdrive( nDrive + 1, &uiTotal ); _dos_getdrive( &uiTotal ); - if( nDrive != uiTotal ) + if( ( nDrive + 1 ) != uiTotal ) { s_uiErrorLast = FS_ERROR; uiResult = FS_ERROR; @@ -1030,9 +1045,29 @@ USHORT hb_fsIsDrv( BYTE nDrive ) return uiResult; } -/* TODO: add documentation - * QUESTION: Is A: drive numbered as 0 or as 1 ? - */ +BOOL hb_fsIsDevice( FHANDLE hFileHandle ) +{ + BOOL bResult; + +#if defined(HAVE_POSIX_IO) && ( defined(OS2) || defined(DOS) || defined(_Windows) || defined(__MINGW32__) ) && ! defined(__CYGWIN__) + + errno = 0; + bResult = ( isatty( hFileHandle ) == 0 ); + s_uiErrorLast = errno; + +#else + + bResult = FALSE; + s_uiErrorLast = FS_ERROR; + +#endif + + return bResult; +} + +/* NOTE: 0=A:, 1=B:, 2=C:, 3=D:, ... */ +/* TODO: add documentation */ + BYTE hb_fsCurDrv( void ) { USHORT uiResult; @@ -1738,16 +1773,6 @@ HARBOUR HB_HB_FNAMEMERGE( void ) hb_retc( hb_fsFNameMerge( szFileName, &pFileName ) ); } -void hb_fsSetDevRaw( FHANDLE hFileHandle ) -{ - hb_fsSetDevMode( hFileHandle, FD_BINARY ); -} - -void hb_fsSetDevText( FHANDLE hFileHandle ) -{ - hb_fsSetDevMode( hFileHandle, FD_TEXT ); -} - /* NOTE: Clipper 5.3 undocumented */ HARBOUR HB_FSETDEVMOD( void ) @@ -1755,4 +1780,3 @@ HARBOUR HB_FSETDEVMOD( void ) if( ISNUM( 1 ) && ISNUM( 2 ) ) hb_fsSetDevMode( hb_parni( 1 ), hb_parni( 2 ) ); } - diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index 3d3b7e10b8..499522a93c 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -959,7 +959,7 @@ void hb_vmExecute( BYTE * pCode, PHB_SYMB pSymbols ) case HB_P_NOOP: /* Intentionally do nothing */ - w += 1; + w++; break; default: