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)
This commit is contained in:
Viktor Szakats
2010-02-13 10:42:35 +00:00
parent 813fde7560
commit 7c2f63f8d6
2 changed files with 50 additions and 0 deletions

View File

@@ -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.

View File

@@ -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 );
}