From c01cc32ee1defa2f61db74652488a90710c5eef4 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Wed, 7 Nov 2007 09:48:22 +0000 Subject: [PATCH] 2007-11-07 10:48 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/common/hbfsapi.c ! fixed DJGPP builds * use _chmod() if available (for long file name support) or _dos_getfileattr() instead of direct interrupt calls --- harbour/ChangeLog | 6 ++++++ harbour/source/common/hbfsapi.c | 38 +++++++++++++++------------------ 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index fb290e7ce0..444916820a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,12 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-11-07 10:48 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/common/hbfsapi.c + ! fixed DJGPP builds + * use _chmod() if available (for long file name support) + or _dos_getfileattr() instead of direct interrupt calls + 2007-11-07 01:47 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rtl/filesys.c * updated hb_fsTell() and hb_fsEof() to respect platform dependent diff --git a/harbour/source/common/hbfsapi.c b/harbour/source/common/hbfsapi.c index d585f6b1e6..a1ccfae2a3 100644 --- a/harbour/source/common/hbfsapi.c +++ b/harbour/source/common/hbfsapi.c @@ -54,13 +54,13 @@ #include "hbapi.h" #include "hbapifs.h" +#include "hb_io.h" #if defined( HB_OS_WIN_32 ) #if !defined( INVALID_FILE_ATTRIBUTES ) #define INVALID_FILE_ATTRIBUTES ( ( DWORD ) -1 ) #endif #elif defined( HB_OS_UNIX ) - #include #include #include #endif @@ -291,16 +291,14 @@ HB_EXPORT BOOL hb_fsFileExists( const char * pszFileName ) #if defined( HB_OS_DOS ) { - union REGS regs; - struct SREGS sregs; - - regs.HB_XREGS.ax = 0x4300; - regs.HB_XREGS.dx = FP_OFF( pszFileName ); - sregs.ds = FP_SEG( pszFileName ); - - HB_DOS_INT86X( 0x21, ®s, ®s, &sregs ); - - fExist = regs.x.cflag == 0 && ( regs.HB_XREGS.cx & 10h ) == 0; +#if defined( __DJGPP__ ) || defined(__BORLANDC__) + int iAttr = _chmod( pszFileName, 0, 0 ); + fExist = iAttr != -1 && ( iAttr & 0x10 ) == 0; +#else + unsigned int iAttr = 0; + fExist = _dos_getfileattr( pszFileName, &iAttr ) == 0 && + ( iAttr & 0x10 ) == 0; +#endif } #elif defined( HB_OS_WIN_32 ) { @@ -347,16 +345,14 @@ HB_EXPORT BOOL hb_fsDirExists( const char * pszDirName ) #if defined( HB_OS_DOS ) { - union REGS regs; - struct SREGS sregs; - - regs.HB_XREGS.ax = 0x4300; - regs.HB_XREGS.dx = FP_OFF( pszDirName ); - sregs.ds = FP_SEG( pszDirName ); - - HB_DOS_INT86X( 0x21, ®s, ®s, &sregs ); - - fExist = regs.x.cflag == 0 && ( regs.HB_XREGS.cx & 10h ); +#if defined( __DJGPP__ ) || defined(__BORLANDC__) + int iAttr = _chmod( pszDirName, 0, 0 ); + fExist = iAttr != -1 && ( iAttr & 0x10 ) != 0; +#else + unsigned int iAttr = 0; + fExist = _dos_getfileattr( pszDirName, &iAttr ) == 0 && + ( iAttr & 0x10 ) != 0; +#endif } #elif defined( HB_OS_WIN_32 ) {