From f939903e37ef459e731d981d63bee0e9215f0c02 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 11 Mar 2010 20:20:13 +0000 Subject: [PATCH] 2010-03-11 21:16 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * src/rtl/filesys.c + Using direct Windows API instead of compiler specific C RTL functions to get/set current disk. ; Please review. - Deleted one Windows TODO: setmode() to be convered to direct Windows API call. This translation is done in C RTL, so Windows API cannot be used. ; There is no remaining non-standard (compiler specific) C RTL function usage on the Windows platform AFAICT. * contrib/hbmysql/tmysql.prg * Formatting. --- harbour/ChangeLog | 26 +++++++++--- harbour/contrib/hbmysql/tmysql.prg | 14 ++----- harbour/src/rtl/filesys.c | 67 +++++++++++++++++++++++++----- 3 files changed, 80 insertions(+), 27 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9ebc79a634..5c5c5b4735 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,20 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-03-11 21:16 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * src/rtl/filesys.c + + Using direct Windows API instead of compiler specific + C RTL functions to get/set current disk. + ; Please review. + - Deleted one Windows TODO: setmode() to be convered to + direct Windows API call. This translation is done in + C RTL, so Windows API cannot be used. + ; There is no remaining non-standard (compiler specific) + C RTL function usage on the Windows platform AFAICT. + + * contrib/hbmysql/tmysql.prg + * Formatting. + 2010-03-11 09:30 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbqt/doc/en/class_hbqplaintextedit.txt * contrib/hbqt/hbqt_hbqplaintextedit.cpp @@ -32,7 +46,7 @@ * contrib/hbide/idethemes.prg + Reimplemented "Themes". * Now it is possible to change current line and line area background - colors. Also synchronized the current colors for these areas + colors. Also synchronized the current colors for these areas with rest of the theme. * Now you can apply a particular theme globally to all tabs. * Made easy the way GUI elements are presented, it is more intuitive. @@ -130786,11 +130800,11 @@ All this changes (except Ron's PP) are my work borrowed from xHarbour. * added 254 as linelength arg for memoline parsing in LoadFromText() - 2002-01-28 21:30 UTC+0100 Patrick Mast - * contrib/mysql/tmysql - + Added DateTime field - * Added more info on Alert message for Unknown type - * Modified ClipValue2SQL() to process empty strings +2002-01-28 21:30 UTC+0100 Patrick Mast + * contrib/mysql/tmysql + + Added DateTime field + * Added more info on Alert message for Unknown type + * Modified ClipValue2SQL() to process empty strings 2002-01-28 20:43 UTC+0100 Patrick Mast * contrib/mysql diff --git a/harbour/contrib/hbmysql/tmysql.prg b/harbour/contrib/hbmysql/tmysql.prg index b96f72033e..c8d54b92e0 100644 --- a/harbour/contrib/hbmysql/tmysql.prg +++ b/harbour/contrib/hbmysql/tmysql.prg @@ -51,14 +51,6 @@ * */ -/* - 2002-01-28 21:30 UTC+0100 Patrick Mast - * contrib/mysql/tmysql - + Added DateTime field - * Added more info on Alert message for Unknown type - * Modified ClipValue2SQL() to process empty strings - */ - #include "hbclass.ch" #include "common.ch" @@ -617,13 +609,13 @@ METHOD FieldPos( cFieldName ) CLASS TMySQLQuery cUpperName := Upper( cFieldName ) - //DAVID: nPos := AScan( ::aFieldStruct, {|aItem| iif( Upper( aItem[ MYSQL_FS_NAME ] ) == cUpperName, .T., .F. ) } ) - nPos := AScan( ::aFieldStruct, {| aItem | Upper( aItem[ MYSQL_FS_NAME ]) == cUpperName } ) + //DAVID: nPos := AScan( ::aFieldStruct, {| aItem | iif( Upper( aItem[ MYSQL_FS_NAME ] ) == cUpperName, .T., .F. ) } ) + nPos := AScan( ::aFieldStruct, {| aItem | Upper( aItem[ MYSQL_FS_NAME ] ) == cUpperName } ) /* nPos := 0 DO WHILE ++nPos <= Len( ::aFieldStruct ) - IF Upper( ::aFieldStruct[nPos][ MYSQL_FS_NAME ] ) == cUpperName + IF Upper( ::aFieldStruct[ nPos ][ MYSQL_FS_NAME ] ) == cUpperName EXIT ENDIF ENDDO diff --git a/harbour/src/rtl/filesys.c b/harbour/src/rtl/filesys.c index ae1f56ea6c..14107493ed 100644 --- a/harbour/src/rtl/filesys.c +++ b/harbour/src/rtl/filesys.c @@ -238,7 +238,12 @@ } while( 0 ) #define HB_FS_SETDRIVE(n) do { DosSetDefaultDisk( ( n ) + 1 ); } while( 0 ) -#elif defined( __DJGPP__ ) || defined( __BORLANDC__ ) || defined( __DMC__ ) +#elif defined( HB_OS_WIN ) + + #define HB_FS_GETDRIVE(n) do { n = fs_win_get_drive(); } while( 0 ) + #define HB_FS_SETDRIVE(n) fs_win_set_drive( n ) + +#elif defined( __DJGPP__ ) || defined( __BORLANDC__ ) /* 0 based version */ #define HB_FS_GETDRIVE(n) do { n = getdisk(); } while( 0 ) @@ -256,7 +261,7 @@ _dos_setdrive( ( n ) + 1, &_u ); \ } while( 0 ) -#else /* _MSC_VER, __POCC__, __XCC__, MINGW, __BORLANDC__, __DMC__ */ +#else /* _MSC_VER */ /* 1 based version */ #define HB_FS_GETDRIVE(n) do { n = _getdrive() - 1; } while( 0 ) @@ -305,6 +310,53 @@ static HB_BOOL s_fUseWaitLocks = HB_TRUE; +#if defined( HB_OS_WIN ) + +static int fs_win_get_drive( void ) +{ + int iDrive; + char szBuffer[ HB_PATH_MAX ]; + PHB_FNAME pFilepath; + +#if defined( UNICODE ) + { + TCHAR lpBuffer[ HB_PATH_MAX ]; + HB_SIZE ulSize = HB_SIZEOFARRAY( lpBuffer ); + hb_fsSetIOError( ( GetCurrentDirectory( ulSize, lpBuffer ) != 0 ), 0 ); + hb_wctombget( szBuffer, lpBuffer, ulSize ); + } +#else + hb_fsSetIOError( ( GetCurrentDirectory( ulSize, szBuffer ) != 0 ), 0 ); +#endif + + pFilepath = hb_fsFNameSplit( szBuffer ); + + if( pFilepath->szDrive ) + iDrive = HB_TOUPPER( pFilepath->szDrive[ 0 ] ) - 'A'; + else + iDrive = -1; + + hb_xfree( pFilepath ); + + return iDrive; +} + +static void fs_win_set_drive( int iDrive ) +{ + if( iDrive >= 0 ) + { + TCHAR szBuffer[ 3 ]; + + szBuffer[ 0 ] = ( TCHAR ) ( iDrive + 'A' ); + szBuffer[ 1 ] = TEXT( ':' ); + szBuffer[ 2 ] = TEXT( '\0' ); + + hb_fsSetIOError( SetCurrentDirectory( szBuffer ), 0 ); + } +} + +#endif + #if defined( HB_FS_FILE_IO ) #if defined( HB_OS_WIN ) @@ -877,8 +929,6 @@ int hb_fsSetDevMode( HB_FHANDLE hFileHandle, int iDevMode ) { HB_TRACE(HB_TR_DEBUG, ("hb_fsSetDevMode(%p, %d)", ( void * ) ( HB_PTRDIFF ) hFileHandle, iDevMode)); - /* TODO: Support using native Windows API */ - #if defined( __BORLANDC__ ) || defined( __IBMCPP__ ) || defined( __DJGPP__ ) || \ defined( __CYGWIN__ ) || defined( __WATCOMC__ ) || defined( HB_OS_OS2 ) { @@ -1840,8 +1890,8 @@ HB_SIZE hb_fsWriteAt( HB_FHANDLE hFileHandle, const void * pBuff, HB_SIZE ulCoun } /* TOFIX: this is not atom operation. It has to be fixed for RDD - * file access with shared file handles in aliased work areas - */ + * file access with shared file handles in aliased work areas + */ # elif defined( HB_FS_LARGE_OPTIMIZED ) { HB_FOFFSET llPos; @@ -3039,9 +3089,7 @@ char * hb_fsExtName( const char * pFilename, const char * pDefExt, pFilepath = hb_fsFNameSplit( pFilename ); if( pDefExt && ( ( uiExFlags & FXO_FORCEEXT ) || !pFilepath->szExtension ) ) - { pFilepath->szExtension = pDefExt; - } if( pFilepath->szPath ) { @@ -3095,9 +3143,8 @@ char * hb_fsExtName( const char * pFilename, const char * pDefExt, } } else - { hb_fsFNameMerge( szPath, pFilepath ); - } + hb_xfree( pFilepath ); return szPath;