2009-12-02 03:12 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/doc/en-EN/hb_apifs.txt
* harbour/include/hbapifs.h
* harbour/src/rtl/filesys.c
* changed:
BOOL hb_fsSetDevMode( HB_FHANDLE hFileHandle, USHORT uiDevMode )
to:
int hb_fsSetDevMode( HB_FHANDLE hFileHandle, int iDevMode )
Now it returns previous mode for hFileHandle or -1 on error.
if iDevMode == 0 then it does not change device mode.
* harbour/src/rtl/philes.c
* modified HB_FSETDEVMODE() function to work with new hb_fsSetDevMode()
Current syntax is:
HB_FSETDEVMODE( <hFile> [, <nNewMode> ] ) -> <nOldMode>
It may return FD_BINARY, FD_TEXT or FS_ERROR.
* harbour/src/rtl/philes53.c
* modified FSETDEVMOD() function to work with new hb_fsSetDevMode()
It's similar to HB_FSETDEVMODE() but returns FD_BINARY instead of
FS_ERROR. Such behavior is more closer to CL53.
* harbour/src/rtl/console.c
* set also STDIN into binary mode
This commit is contained in:
@@ -17,6 +17,31 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2009-12-02 03:12 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/doc/en-EN/hb_apifs.txt
|
||||
* harbour/include/hbapifs.h
|
||||
* harbour/src/rtl/filesys.c
|
||||
* changed:
|
||||
BOOL hb_fsSetDevMode( HB_FHANDLE hFileHandle, USHORT uiDevMode )
|
||||
to:
|
||||
int hb_fsSetDevMode( HB_FHANDLE hFileHandle, int iDevMode )
|
||||
Now it returns previous mode for hFileHandle or -1 on error.
|
||||
if iDevMode == 0 then it does not change device mode.
|
||||
|
||||
* harbour/src/rtl/philes.c
|
||||
* modified HB_FSETDEVMODE() function to work with new hb_fsSetDevMode()
|
||||
Current syntax is:
|
||||
HB_FSETDEVMODE( <hFile> [, <nNewMode> ] ) -> <nOldMode>
|
||||
It may return FD_BINARY, FD_TEXT or FS_ERROR.
|
||||
|
||||
* harbour/src/rtl/philes53.c
|
||||
* modified FSETDEVMOD() function to work with new hb_fsSetDevMode()
|
||||
It's similar to HB_FSETDEVMODE() but returns FD_BINARY instead of
|
||||
FS_ERROR. Such behavior is more closer to CL53.
|
||||
|
||||
* harbour/src/rtl/console.c
|
||||
* set also STDIN into binary mode
|
||||
|
||||
2009-12-01 18:09 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
|
||||
* contrib/hbide/hbide.prg
|
||||
* contrib/hbxbp/xbpstatusbar.prg
|
||||
|
||||
@@ -1069,13 +1069,13 @@
|
||||
* C Prototype
|
||||
*
|
||||
* #include <hbapifs.h>
|
||||
* hb_fsSetDevMode( HB_FHANDLE hFileHandle, USHORT uiDevMode ) --> BOOL
|
||||
* hb_fsSetDevMode( HB_FHANDLE hFileHandle, int iDevMode ) --> int
|
||||
* $ARGUMENTS$
|
||||
* <hFileHandle>
|
||||
*
|
||||
* <uiDevMode>
|
||||
* <iDevMode>
|
||||
* $RETURNS$
|
||||
* TRUE when successful, FALSE when not.
|
||||
* previous mode or -1 on error
|
||||
* $DESCRIPTION$
|
||||
*
|
||||
* $EXAMPLES$
|
||||
|
||||
@@ -192,7 +192,7 @@ extern HB_EXPORT BOOL hb_fsRename ( const char * pszOldName, const ch
|
||||
extern HB_EXPORT ULONG hb_fsSeek ( HB_FHANDLE hFileHandle, LONG lOffset, USHORT uiMode ); /* reposition an open file */
|
||||
extern HB_EXPORT HB_FOFFSET hb_fsSeekLarge ( HB_FHANDLE hFileHandle, HB_FOFFSET llOffset, USHORT uiFlags ); /* reposition an open file using 64bit API */
|
||||
extern HB_EXPORT ULONG hb_fsTell ( HB_FHANDLE hFileHandle ); /* retrieve the current position of a file */
|
||||
extern HB_EXPORT BOOL hb_fsSetDevMode ( HB_FHANDLE hFileHandle, USHORT uiDevMode ); /* change the device mode of a file (text/binary) */
|
||||
extern HB_EXPORT int hb_fsSetDevMode ( HB_FHANDLE hFileHandle, int iDevMode ); /* change the device mode of a file (text/binary) */
|
||||
extern HB_EXPORT BOOL hb_fsGetFileTime ( const char * pszFileName, long * plJulian, long * plMillisec );
|
||||
extern HB_EXPORT BOOL hb_fsSetFileTime ( const char * pszFileName, long lJulian, long lMillisec );
|
||||
extern HB_EXPORT BOOL hb_fsGetAttr ( const char * pszFileName, ULONG * pulAttr );
|
||||
|
||||
@@ -154,6 +154,7 @@ void hb_conInit( void )
|
||||
* Some compilers open stdout and stderr in text mode, but
|
||||
* Harbour needs them to be open in binary mode.
|
||||
*/
|
||||
hb_fsSetDevMode( s_hFilenoStdin, FD_BINARY );
|
||||
hb_fsSetDevMode( s_hFilenoStdout, FD_BINARY );
|
||||
hb_fsSetDevMode( s_hFilenoStderr, FD_BINARY );
|
||||
|
||||
@@ -183,6 +184,7 @@ void hb_conRelease( void )
|
||||
|
||||
hb_gtExit();
|
||||
|
||||
hb_fsSetDevMode( s_hFilenoStdin, FD_TEXT );
|
||||
hb_fsSetDevMode( s_hFilenoStdout, FD_TEXT );
|
||||
hb_fsSetDevMode( s_hFilenoStderr, FD_TEXT );
|
||||
}
|
||||
|
||||
@@ -842,53 +842,66 @@ void hb_fsClose( HB_FHANDLE hFileHandle )
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOL hb_fsSetDevMode( HB_FHANDLE hFileHandle, USHORT uiDevMode )
|
||||
|
||||
#define FD_TEST 0
|
||||
|
||||
int hb_fsSetDevMode( HB_FHANDLE hFileHandle, int iDevMode )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_fsSetDevMode(%p, %hu)", ( void * ) ( HB_PTRDIFF ) hFileHandle, uiDevMode));
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_fsSetDevMode(%p, %d)", ( void * ) ( HB_PTRDIFF ) hFileHandle, iDevMode));
|
||||
|
||||
/* TODO: HB_IO_WIN support */
|
||||
|
||||
#if defined( __BORLANDC__ ) || defined( __IBMCPP__ ) || defined( __DJGPP__ ) || \
|
||||
defined( __CYGWIN__ ) || defined( __WATCOMC__ ) || defined( HB_OS_OS2 )
|
||||
{
|
||||
int iRet = 0;
|
||||
int iRet = -1;
|
||||
|
||||
#if defined( HB_IO_WIN )
|
||||
if( hFileHandle != ( HB_FHANDLE ) 0 &&
|
||||
hFileHandle != ( HB_FHANDLE ) 1 &&
|
||||
hFileHandle != ( HB_FHANDLE ) 2 )
|
||||
iRet = -1;
|
||||
else
|
||||
if( hFileHandle == ( HB_FHANDLE ) 0 ||
|
||||
hFileHandle == ( HB_FHANDLE ) 1 ||
|
||||
hFileHandle == ( HB_FHANDLE ) 2 )
|
||||
#endif
|
||||
switch( uiDevMode )
|
||||
switch( iDevMode )
|
||||
{
|
||||
case FD_TEST:
|
||||
iRet = setmode( ( int ) hFileHandle, O_BINARY );
|
||||
if( iRet != -1 )
|
||||
setmode( ( int ) hFileHandle, iRet );
|
||||
break;
|
||||
|
||||
case FD_BINARY:
|
||||
iRet = setmode( ( HB_NHANDLE ) hFileHandle, O_BINARY );
|
||||
iRet = setmode( ( int ) hFileHandle, O_BINARY );
|
||||
break;
|
||||
|
||||
case FD_TEXT:
|
||||
iRet = setmode( ( HB_NHANDLE ) hFileHandle, O_TEXT );
|
||||
iRet = setmode( ( int ) hFileHandle, O_TEXT );
|
||||
break;
|
||||
}
|
||||
|
||||
if( iRet != -1 )
|
||||
iRet = ( iRet & O_TEXT ) == O_TEXT ? FD_TEXT : FD_BINARY;
|
||||
hb_fsSetIOError( iRet != -1, 0 );
|
||||
|
||||
return iRet != -1;
|
||||
return iRet;
|
||||
}
|
||||
#elif ( defined( _MSC_VER ) || defined( __MINGW32__ ) || defined( __DMC__ ) ) && \
|
||||
!defined( HB_OS_WIN_CE )
|
||||
{
|
||||
int iRet = 0;
|
||||
int iRet = -1;
|
||||
|
||||
#if defined( HB_IO_WIN )
|
||||
if( hFileHandle != ( HB_FHANDLE ) 0 &&
|
||||
hFileHandle != ( HB_FHANDLE ) 1 &&
|
||||
hFileHandle != ( HB_FHANDLE ) 2 )
|
||||
iRet = -1;
|
||||
else
|
||||
if( hFileHandle == ( HB_FHANDLE ) 0 ||
|
||||
hFileHandle == ( HB_FHANDLE ) 1 ||
|
||||
hFileHandle == ( HB_FHANDLE ) 2 )
|
||||
#endif
|
||||
switch( uiDevMode )
|
||||
switch( iDevMode )
|
||||
{
|
||||
case FD_TEST:
|
||||
iRet = _setmode( ( int ) hFileHandle, _O_BINARY );
|
||||
if( iRet != -1 )
|
||||
_setmode( ( int ) hFileHandle, iRet );
|
||||
break;
|
||||
|
||||
case FD_BINARY:
|
||||
iRet = _setmode( ( int ) hFileHandle, _O_BINARY );
|
||||
break;
|
||||
@@ -898,27 +911,18 @@ BOOL hb_fsSetDevMode( HB_FHANDLE hFileHandle, USHORT uiDevMode )
|
||||
break;
|
||||
}
|
||||
|
||||
if( iRet != -1 )
|
||||
iRet = ( iRet & _O_TEXT ) == _O_TEXT ? FD_TEXT : FD_BINARY;
|
||||
hb_fsSetIOError( iRet != -1, 0 );
|
||||
|
||||
return iRet != -1;
|
||||
return iRet;
|
||||
}
|
||||
#elif defined( HB_OS_UNIX ) || defined( HB_OS_WIN_CE )
|
||||
#else
|
||||
|
||||
HB_SYMBOL_UNUSED( hFileHandle );
|
||||
|
||||
if( uiDevMode == FD_TEXT )
|
||||
{
|
||||
hb_fsSetError( ( HB_ERRCODE ) FS_ERROR );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
hb_fsSetError( 0 );
|
||||
return TRUE;
|
||||
|
||||
#else
|
||||
|
||||
hb_fsSetError( ( HB_ERRCODE ) FS_ERROR );
|
||||
return FALSE;
|
||||
hb_fsSetError( ( HB_ERRCODE ) ( iDevMode == FD_TEXT ? FS_ERROR : 0 ) );
|
||||
return FD_BINARY;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -419,16 +419,17 @@ HB_FUNC( HB_FGETDATETIME )
|
||||
|
||||
HB_FUNC( HB_FSETDEVMODE )
|
||||
{
|
||||
/* C53 checks only number of parameters: hb_pcount() == 2 */
|
||||
if( HB_ISNUM( 1 ) && HB_ISNUM( 2 ) )
|
||||
int iRet = -1;
|
||||
|
||||
if( HB_ISNUM( 1 ) )
|
||||
{
|
||||
hb_fsSetDevMode( hb_numToHandle( hb_parnint( 1 ) ), ( USHORT ) hb_parni( 2 ) );
|
||||
iRet = hb_fsSetDevMode( hb_numToHandle( hb_parnint( 1 ) ), hb_parni( 2 ) );
|
||||
hb_fsSetFError( hb_fsError() );
|
||||
}
|
||||
/* NOTE: INCOMPATIBILITY! C53 will return the device flags
|
||||
before applying the new setting, Harbour will
|
||||
always return 0. [vszakats] */
|
||||
hb_retni( 0 );
|
||||
else
|
||||
hb_fsSetFError( 6 ); /* ERROR_INVALID_HANDLE */
|
||||
|
||||
hb_retni( iRet );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_OSERROR )
|
||||
|
||||
@@ -57,11 +57,21 @@
|
||||
|
||||
/* NOTE: Clipper 5.3 undocumented */
|
||||
|
||||
HB_FUNC_EXTERN( HB_FSETDEVMODE );
|
||||
|
||||
HB_FUNC( FSETDEVMOD )
|
||||
{
|
||||
HB_FUNC_EXEC( HB_FSETDEVMODE );
|
||||
int iRet = FD_BINARY;
|
||||
|
||||
if( HB_ISNUM( 1 ) )
|
||||
{
|
||||
iRet = hb_fsSetDevMode( hb_numToHandle( hb_parnint( 1 ) ), hb_parni( 2 ) );
|
||||
if( iRet != FD_TEXT )
|
||||
iRet = FD_BINARY;
|
||||
hb_fsSetFError( hb_fsError() );
|
||||
}
|
||||
else
|
||||
hb_fsSetFError( 6 ); /* ERROR_INVALID_HANDLE */
|
||||
|
||||
hb_retni( iRet );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user