From cfdacbcef1cbbf95f08e2d203f55f12d22f2521b Mon Sep 17 00:00:00 2001 From: Mindaugas Kavaliauskas Date: Fri, 2 Nov 2007 16:57:00 +0000 Subject: [PATCH] 2007-11-02 18:52 UTC+0200 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt) * harbour/source/common/hbfsapi.c ! fixed hb_fsFileExists() to return TRUE for files only --- harbour/ChangeLog | 4 ++++ harbour/source/common/hbfsapi.c | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a6be2a9a9c..2e5924551d 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,10 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-11-02 18:52 UTC+0200 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt) + * harbour/source/common/hbfsapi.c + ! fixed hb_fsFileExists() to return TRUE for files only + 2007-11-02 16:04 UTC+0100 Miguel Angel Marchuet Frutos * contrib/bmdbfcdx/bmdbfcdx1.c ! fixed undoing previous fix diff --git a/harbour/source/common/hbfsapi.c b/harbour/source/common/hbfsapi.c index 6b8f1a8e7f..71c46be602 100644 --- a/harbour/source/common/hbfsapi.c +++ b/harbour/source/common/hbfsapi.c @@ -299,13 +299,18 @@ HB_EXPORT BOOL hb_fsFileExists( const char * pszFileName ) } #elif defined( HB_OS_WIN_32 ) { - return GetFileAttributesA( pszFileName ) != INVALID_FILE_ATTRIBUTES; + DWORD dwAttr; + + dwAttr = GetFileAttributesA( pszFileName ); + return ( dwAttr != INVALID_FILE_ATTRIBUTES ) && + ( dwAttr & ( FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE ) ) == 0; } #elif defined( HB_OS_UNIX ) { struct stat statbuf; - return stat( pszFileName, &statbuf ) == 0; + return stat( pszFileName, &statbuf ) == 0 && + ( statbuf.st_mode & S_IFMT ) == S_IFREG; } #else {