2007-11-04 03:40 UTC+0200 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt)

* include/hbapifs.h
  * harbour/source/common/hbfsapi.c
    ! fixed hb_fsFileExists() for DOS 
    + Added hb_fsDirExists()

  * include/hbextern.ch
  * source/rtl/hbfile.c
    + Added HB_DIREXISTS()
This commit is contained in:
Mindaugas Kavaliauskas
2007-11-04 01:40:13 +00:00
parent 7bad05f1b6
commit 7eb0a16404
5 changed files with 73 additions and 1 deletions

View File

@@ -8,6 +8,16 @@
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2007-11-04 03:40 UTC+0200 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt)
* include/hbapifs.h
* harbour/source/common/hbfsapi.c
! fixed hb_fsFileExists() for DOS
+ Added hb_fsDirExists()
* include/hbextern.ch
* source/rtl/hbfile.c
+ Added HB_DIREXISTS()
2007-11-04 02:34 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbapi.h
* harbour/source/common/hbstr.c

View File

@@ -148,6 +148,7 @@ extern HB_EXPORT FHANDLE hb_fsGetOsHandle( FHANDLE hFileHandle );
extern HB_EXPORT USHORT hb_fsGetFError ( void ); /* get FERROR() flag */
extern HB_EXPORT void hb_fsSetFError ( USHORT uiError ); /* set FERROR() flag */
extern HB_EXPORT BOOL hb_fsFileExists ( const char * pszFileName ); /* check if a file exists (wildcard chars not accepted). */
extern HB_EXPORT BOOL hb_fsDirExists ( const char * pszDirName ); /* check if a directory exists (wildcard chars not accepted). */
#define hb_fsFLock( h, s, l ) hb_fsLock( h, s, l, FL_LOCK )
#define hb_fsFUnlock( h, s, l ) hb_fsLock( h, s, l, FL_UNLOCK )

View File

@@ -781,6 +781,7 @@ EXTERNAL HB_COMPILER
EXTERNAL HB_PCODEVER
EXTERNAL HB_BUILDDATE
EXTERNAL HB_FILEEXISTS
EXTERNAL HB_DIREXISTS
EXTERNAL HB_FNAMEMERGE
EXTERNAL HB_FNAMESPLIT
EXTERNAL HB_LANGNAME

View File

@@ -300,7 +300,7 @@ HB_EXPORT BOOL hb_fsFileExists( const char * pszFileName )
HB_DOS_INT86X( 0x21, &regs, &regs, &sregs );
fExist = regs.x.cflag == 0;
fExist = regs.x.cflag == 0 && ( regs.HB_XREGS.cx & 10h ) == 0;
}
#elif defined( HB_OS_WIN_32 )
{
@@ -331,3 +331,58 @@ HB_EXPORT BOOL hb_fsFileExists( const char * pszFileName )
return fExist;
}
HB_EXPORT BOOL hb_fsDirExists( const char * pszDirName )
{
BOOL fExist;
BOOL fFree;
HB_TRACE(HB_TR_DEBUG, ("hb_fsDirExists(%p)", pszDirName));
if( pszDirName == NULL )
return FALSE;
pszDirName = ( char * ) hb_fsNameConv( ( BYTE * ) pszDirName, &fFree );
#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, &regs, &regs, &sregs );
fExist = regs.x.cflag == 0 && ( regs.HB_XREGS.cx & 10h );
}
#elif defined( HB_OS_WIN_32 )
{
DWORD dwAttr;
dwAttr = GetFileAttributesA( pszDirName );
fExist = ( dwAttr != INVALID_FILE_ATTRIBUTES ) &&
( dwAttr & FILE_ATTRIBUTE_DIRECTORY );
}
#elif defined( HB_OS_UNIX )
{
struct stat statbuf;
fExist = stat( pszDirName, &statbuf ) == 0 &&
S_ISDIR( statbuf.st_mode );
}
#else
{
int TODO; /* To force warning */
fExist = FALSE;
}
#endif
if( fFree )
hb_xfree( ( void * ) pszDirName );
return fExist;
}

View File

@@ -57,3 +57,8 @@ HB_FUNC( HB_FILEEXISTS )
{
hb_retl( hb_fsFileExists( hb_parc( 1 ) ) );
}
HB_FUNC( HB_DIREXISTS )
{
hb_retl( hb_fsDirExists( hb_parc( 1 ) ) );
}