From 69941dbb06fcb102242c8822823d780e44d65157 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Mon, 15 Jun 2009 16:29:58 +0000 Subject: [PATCH] 2009-06-15 18:39 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rtl/fstemp.c * harbour/source/rtl/filesys.c * convert '/' to '\' in hb_fTempCreate*()/CurDir() functions in DJGPP builds --- harbour/ChangeLog | 6 ++++++ harbour/source/rtl/filesys.c | 28 ++++++++++++++++++---------- harbour/source/rtl/fstemp.c | 19 +++++++++++++++++++ 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index aa0d05b5f2..d8ac617fe5 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,12 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-06-15 18:39 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/rtl/fstemp.c + * harbour/source/rtl/filesys.c + * convert '/' to '\' in hb_fTempCreate*()/CurDir() functions in + DJGPP builds + 2009-06-15 08:41 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * harbour/contrib/hbxbp/apig.ch * harbour/contrib/hbxbp/gra.ch diff --git a/harbour/source/rtl/filesys.c b/harbour/source/rtl/filesys.c index b95ee4bb89..55acd2924e 100644 --- a/harbour/source/rtl/filesys.c +++ b/harbour/source/rtl/filesys.c @@ -2594,6 +2594,7 @@ BYTE * hb_fsCurDir( USHORT uiDrive ) USHORT hb_fsCurDirBuff( USHORT uiDrive, BYTE * pbyBuffer, ULONG ulLen ) { USHORT uiCurDrv = uiDrive, usError; + BYTE * pbyStart; BOOL fResult; HB_TRACE(HB_TR_DEBUG, ("hb_fsCurDirBuff(%hu)", uiDrive)); @@ -2605,7 +2606,9 @@ USHORT hb_fsCurDirBuff( USHORT uiDrive, BYTE * pbyBuffer, ULONG ulLen ) * It will allow us to add drive emulation in hb_fsCurDrv()/hb_fsChDrv() * and hb_fsNameConv() */ -#if !( defined(__GNUC__) && ( defined(HB_OS_OS2) || !defined(__MINGW32__) ) ) +#if defined(HB_OS_WIN) || \ + ( !( defined(HB_OS_OS2) && defined(__GNUC__) ) && \ + !defined(__MINGW32__) && defined(HAVE_POSIX_IO) ) if( uiDrive ) { uiCurDrv = hb_fsCurDrv() + 1; @@ -2628,13 +2631,6 @@ USHORT hb_fsCurDirBuff( USHORT uiDrive, BYTE * pbyBuffer, ULONG ulLen ) hb_fsSetIOError( fResult, 0 ); hb_vmLock(); -#elif defined(HAVE_POSIX_IO) - - hb_vmUnlock(); - fResult = ( getcwd( ( char * ) pbyBuffer, ulLen ) != NULL ); - hb_fsSetIOError( fResult, 0 ); - hb_vmLock(); - #elif defined(__MINGW32__) hb_vmUnlock(); @@ -2642,6 +2638,13 @@ USHORT hb_fsCurDirBuff( USHORT uiDrive, BYTE * pbyBuffer, ULONG ulLen ) hb_fsSetIOError( fResult, 0 ); hb_vmLock(); +#elif defined(HAVE_POSIX_IO) + + hb_vmUnlock(); + fResult = ( getcwd( ( char * ) pbyBuffer, ulLen ) != NULL ); + hb_fsSetIOError( fResult, 0 ); + hb_vmLock(); + #else fResult = FALSE; @@ -2661,12 +2664,17 @@ USHORT hb_fsCurDirBuff( USHORT uiDrive, BYTE * pbyBuffer, ULONG ulLen ) if( usError == 0 && pbyBuffer[ 0 ] ) { - BYTE * pbyStart = pbyBuffer; - /* Strip the leading drive spec, and leading backslash if there's one. */ /* NOTE: A trailing underscore is not returned on this platform, so we don't need to strip it. [vszakats] */ +#if defined(__DJGPP__) + /* convert '/' to '\' */ + while( ( pbyStart = ( BYTE * ) strchr( ( char * ) pbyBuffer, '/' ) ) != NULL ) + *pbyStart = '\\'; +#endif + + pbyStart = pbyBuffer; ulLen = strlen( ( char * ) pbyBuffer ); #if defined(HB_OS_HAS_DRIVE_LETTER) diff --git a/harbour/source/rtl/fstemp.c b/harbour/source/rtl/fstemp.c index 2913097221..c800b048d9 100644 --- a/harbour/source/rtl/fstemp.c +++ b/harbour/source/rtl/fstemp.c @@ -88,6 +88,16 @@ static BOOL fsGetTempDirByCase( BYTE * pszName, const char * pszTempDir ) } } +# if defined(__DJGPP__) + if( fOK ) + { + /* convert '/' to '\' */ + char * pszDelim; + while( ( pszDelim = strchr( ( char * ) pszName, '/' ) ) != NULL ) + *pszDelim = '\\'; + } +# endif + return fOK; } #endif @@ -230,6 +240,15 @@ static BOOL hb_fsTempName( BYTE * pszBuffer, const BYTE * pszDir, const BYTE * p pszBuffer[ 0 ] = '\0'; fResult = ( tmpnam( ( char * ) pszBuffer ) != NULL ); +# if defined(__DJGPP__) + { + /* convert '/' to '\' */ + char * pszDelim; + while( ( pszDelim = strchr( ( char * ) pszBuffer, '/' ) ) != NULL ) + *pszDelim = '\\'; + } +# endif + #endif hb_fsSetIOError( fResult, 0 );