From 7c2f63f8d6a700609e081d7737ad6fbfe7ccdfda Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 13 Feb 2010 10:42:35 +0000 Subject: [PATCH] 2010-02-13 11:42 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbwin/wapi_winbase.c + Added WAPI_GETLONGPATHNAME() (same code as the short version) --- harbour/ChangeLog | 4 +++ harbour/contrib/hbwin/wapi_winbase.c | 46 ++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index bd628f1657..2a5c9fcebc 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,10 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-02-13 11:42 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbwin/wapi_winbase.c + + Added WAPI_GETLONGPATHNAME() (same code as the short version) + 2010-02-13 11:29 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbwin/win_dll.c % Optimization steps. diff --git a/harbour/contrib/hbwin/wapi_winbase.c b/harbour/contrib/hbwin/wapi_winbase.c index f3eda22905..88267c2bec 100644 --- a/harbour/contrib/hbwin/wapi_winbase.c +++ b/harbour/contrib/hbwin/wapi_winbase.c @@ -341,3 +341,49 @@ HB_FUNC( WAPI_GETSHORTPATHNAME ) hb_retnl( length ); hb_strfree( hLongPath ); } + +HB_FUNC( WAPI_GETLONGPATHNAME ) +{ + void * hLongPath; + DWORD length = 0; + LPCTSTR lpszLongPath = HB_PARSTR( 1, &hLongPath, NULL ); + + if( lpszLongPath ) + { + if( HB_ISBYREF( 2 ) ) + { + TCHAR buffer[ HB_PATH_MAX ]; + DWORD cchBuffer = ( DWORD ) HB_SIZEOFARRAY( buffer ); + LPTSTR lpszShortPath = buffer; + HB_BOOL fSize = HB_ISNUM( 3 ); + + if( fSize ) /* the size of buffer is limited by user */ + { + cchBuffer = ( DWORD ) hb_parnl( 3 ); + if( cchBuffer == 0 ) + lpszShortPath = NULL; + else if( cchBuffer > ( DWORD ) HB_SIZEOFARRAY( buffer ) ) + lpszShortPath = ( LPTSTR ) hb_xgrab( cchBuffer * sizeof( TCHAR ) ); + } + + length = GetLongPathName( lpszLongPath, lpszShortPath, cchBuffer ); + if( !fSize && length > cchBuffer ) /* default buffer size was too small */ + { + cchBuffer = length; + lpszShortPath = ( LPTSTR ) hb_xgrab( cchBuffer * sizeof( TCHAR ) ); + length = GetLongPathName( lpszLongPath, lpszShortPath, cchBuffer ); + } + hbwapi_SetLastError( GetLastError() ); + HB_STORSTRLEN( lpszShortPath, length > cchBuffer ? 0 : length, 2 ); + if( lpszShortPath && lpszShortPath != buffer ) + hb_xfree( lpszShortPath ); + } + else + { + length = GetLongPathName( lpszLongPath, NULL, 0 ); + hbwapi_SetLastError( GetLastError() ); + } + } + hb_retnl( length ); + hb_strfree( hLongPath ); +}