From 16ad8bfcb3022d6630ee686b6bbd79f90ef0a393 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 24 Apr 2012 00:19:21 +0000 Subject: [PATCH] 2012-04-24 02:16 UTC+0200 Viktor Szakats (harbour syenar.net) * src/rtl/filesys.c % fs_win_get_drive() simplified for win platform, eliminated mb conversion. Code posted by Przemek. --- harbour/ChangeLog | 5 +++++ harbour/src/rtl/filesys.c | 30 +++++++++--------------------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 74f46db1d5..d7160f3de0 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,11 @@ The license applies to all entries newer than 2009-04-28. */ +2012-04-24 02:16 UTC+0200 Viktor Szakats (harbour syenar.net) + * src/rtl/filesys.c + % fs_win_get_drive() simplified for win platform, eliminated + mb conversion. Code posted by Przemek. + 2012-04-23 20:31 UTC+0200 Viktor Szakats (harbour syenar.net) * utils/hbmk2/hbmk2.prg + added experimental framework for -ku: option. It is diff --git a/harbour/src/rtl/filesys.c b/harbour/src/rtl/filesys.c index 34a9331303..0f1788e883 100644 --- a/harbour/src/rtl/filesys.c +++ b/harbour/src/rtl/filesys.c @@ -347,29 +347,17 @@ static HB_BOOL s_fUseWaitLocks = HB_TRUE; static int fs_win_get_drive( void ) { + TCHAR lpBuffer[ HB_PATH_MAX ]; int iDrive; - char szBuffer[ HB_PATH_MAX ]; - PHB_FNAME pFilepath; - -#if defined( UNICODE ) - { - TCHAR lpBuffer[ HB_PATH_MAX ]; - hb_fsSetIOError( GetCurrentDirectory( HB_SIZEOFARRAY( lpBuffer ), lpBuffer ) != 0, 0 ); - lpBuffer[ HB_SIZEOFARRAY( lpBuffer ) - 1 ] = L'\0'; - hb_wcntombcpy( szBuffer, lpBuffer, HB_SIZEOFARRAY( lpBuffer ) - 1 ); - } -#else - hb_fsSetIOError( GetCurrentDirectory( HB_SIZEOFARRAY( szBuffer ), szBuffer ) != 0, 0 ); -#endif - - pFilepath = hb_fsFNameSplit( szBuffer ); - - if( pFilepath->szDrive ) - iDrive = HB_TOUPPER( pFilepath->szDrive[ 0 ] ) - 'A'; + lpBuffer[ 0 ] = TEXT( '\0' ); + hb_fsSetIOError( + GetCurrentDirectory( HB_SIZEOFARRAY( lpBuffer ), lpBuffer ) != 0, 0 ); + iDrive = HB_TOUPPER( lpBuffer[ 0 ] ); + if( iDrive >= 'A' && iDrive <= 'Z' && + lpBuffer[ 1 ] == HB_OS_DRIVE_DELIM_CHR ) + iDrive -= 'A'; else - iDrive = 0; - - hb_xfree( pFilepath ); + iDrive = 0; return iDrive; }