From bb14033f3af0db7c2d7413c3c7aa671b0ddbbda9 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Mon, 4 Oct 2010 11:22:45 +0000 Subject: [PATCH] 2010-10-04 13:22 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/rtl/fstemp.c * disabled using tmpnam() in OS2 builds % small code cleanup --- harbour/ChangeLog | 5 +++++ harbour/src/rtl/fstemp.c | 39 ++++++++++++++++++--------------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6b7a20fd4c..628c05fad5 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,11 @@ The license applies to all entries newer than 2009-04-28. */ +2010-10-04 13:22 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/src/rtl/fstemp.c + * disabled using tmpnam() in OS2 builds + % small code cleanup + 2010-10-04 12:43 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/sddpg/sddpg.c ! fixed access to uninitialized pItem variable diff --git a/harbour/src/rtl/fstemp.c b/harbour/src/rtl/fstemp.c index e8a97b72c5..3bd02cbd49 100644 --- a/harbour/src/rtl/fstemp.c +++ b/harbour/src/rtl/fstemp.c @@ -120,15 +120,17 @@ static HB_BOOL fsGetTempDirByCase( char * pszName, const char * pszTempDir ) } } -# if defined( __DJGPP__ ) if( fOK ) { +# if defined( __DJGPP__ ) /* convert '/' to '\' */ char * pszDelim; while( ( pszDelim = strchr( pszName, '/' ) ) != NULL ) *pszDelim = '\\'; - } # endif + if( ! hb_fsDirExists( pszTempDir ) ) + fOK = HB_FALSE; + } return fOK; } @@ -365,7 +367,7 @@ HB_ERRCODE hb_fsTempDir( char * pszTempDir ) if( pszTempDirEnv ) hb_xfree( pszTempDirEnv ); - if( pszTempDir[ 0 ] != '\0' ) + if( nResult == 0 && pszTempDir[ 0 ] != '\0' ) { int len = ( int ) strlen( pszTempDir ); if( pszTempDir[ len - 1 ] != HB_OS_PATH_DELIM_CHR ) @@ -373,6 +375,12 @@ HB_ERRCODE hb_fsTempDir( char * pszTempDir ) pszTempDir[ len ] = HB_OS_PATH_DELIM_CHR; pszTempDir[ len + 1 ] = '\0'; } + else + { + pszTempDir[ 0 ] = '.'; + pszTempDir[ 1 ] = HB_OS_PATH_DELIM_CHR; + pszTempDir[ 2 ] = '\0'; + } } } #elif defined( HB_OS_WIN ) @@ -388,29 +396,18 @@ HB_ERRCODE hb_fsTempDir( char * pszTempDir ) } #else { +#elif !defined( HB_OS_OS2 ) char szBuffer[ L_tmpnam ]; if( tmpnam( szBuffer ) != NULL ) { -# if defined( __DJGPP__ ) - { - /* convert '/' to '\' */ - char * pszDelim; - while( ( pszDelim = strchr( szBuffer, '/' ) ) != NULL ) - *pszDelim = '\\'; - } -# endif - - { - PHB_FNAME pTempName = hb_fsFNameSplit( szBuffer ); - hb_strncpy( pszTempDir, pTempName->szPath, HB_PATH_MAX - 1 ); - hb_xfree( pTempName ); - - if( hb_fsDirExists( pszTempDir ) ) - nResult = 0; - } + PHB_FNAME pTempName = hb_fsFNameSplit( szBuffer ); + if( fsGetTempDirByCase( pszTempDir, pTempName->szPath ) ) + nResult = 0; + hb_xfree( pTempName ); } if( nResult != 0 ) +#endif { static const char * env_tmp[] = { "TEMP", "TMP", "TMPDIR", NULL }; @@ -427,7 +424,7 @@ HB_ERRCODE hb_fsTempDir( char * pszTempDir ) hb_xfree( pszTempDirEnv ); } } - if( pszTempDir[ 0 ] != '\0' ) + if( nResult == 0 && pszTempDir[ 0 ] != '\0' ) { int len = ( int ) strlen( pszTempDir ); if( pszTempDir[ len - 1 ] != HB_OS_PATH_DELIM_CHR )