2009-02-06 11:26 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/source/rtl/philes.c
  * harbour/source/rtl/dirdrive.c
  * harbour/source/rtl/philesx.c
  * harbour/source/rtl/filesys.c
    ! fixed CURDRIVE() and DISKNAME() to not return "A" in OS-es which
      does not use drive letters
    ! eliminated toupper()
    % minor cleanup and speed improvement

  * harbour/config/bin.cf
  * harbour/config/test.cf
    * removed quoting for TOP=$(GRANDP) nested GNU make call parameters
This commit is contained in:
Przemyslaw Czerpak
2009-02-06 10:21:51 +00:00
parent 32cf59595f
commit 75890d9bb2
8 changed files with 106 additions and 46 deletions

View File

@@ -8,6 +8,20 @@
2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
*/
2009-02-06 11:26 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/source/rtl/philes.c
* harbour/source/rtl/dirdrive.c
* harbour/source/rtl/philesx.c
* harbour/source/rtl/filesys.c
! fixed CURDRIVE() and DISKNAME() to not return "A" in OS-es which
does not use drive letters
! eliminated toupper()
% minor cleanup and speed improvement
* harbour/config/bin.cf
* harbour/config/test.cf
* removed quoting for TOP=$(GRANDP) nested GNU make call parameters
2009-02-06 10:55 UTC+0100 Maurilio Longo (maurilio.longo@libero.it)
* config/os2/dir.cf
* use $(COMSPEC) instead of calling cmd.exe directly

View File

@@ -31,7 +31,7 @@ ALL_OBJS = $(ALL_C_OBJS) $(ALL_PRG_OBJS)
first:: dirbase descend
descend:: dirbase
+@$(MK) -C $(ARCH_DIR) -f $(GRANDP)Makefile 'TOP=$(GRANDP)' $(EXE_NAME) $(MK_USR)
+@$(MK) -C $(ARCH_DIR) -f $(GRANDP)Makefile TOP=$(GRANDP) $(EXE_NAME) $(MK_USR)
$(EXE_NAME) : $(ALL_OBJS)
$(LD_RULE)

View File

@@ -11,7 +11,7 @@ include $(TOP)$(ROOT)config/prg.cf
first:: dirbase ^^^d^e^s^c^e^n^d^^^
^^^d^e^s^c^e^n^d^^^ :
@$(MK) -C $(ARCH_DIR) -f $(GRANDP)Makefile 'TOP=$(GRANDP)' $(PRG_EXES)
@$(MK) -C $(ARCH_DIR) -f $(GRANDP)Makefile TOP=$(GRANDP) $(PRG_EXES)
endif
endif

View File

@@ -92,24 +92,44 @@ HB_FUNC( DIRREMOVE )
HB_FUNC( ISDISK )
{
hb_retl( ( ISCHAR( 1 ) && hb_parclen( 1 ) > 0 ) ?
hb_fsIsDrv( ( BYTE )( toupper( *hb_parc( 1 ) ) - 'A' ) ) == 0 :
FALSE );
BOOL fResult = FALSE;
char * szDrive = hb_parc( 1 );
if( szDrive )
{
if( *szDrive >= 'A' && *szDrive <= 'Z' )
fResult = hb_fsIsDrv( *szDrive - 'A' );
else if( *szDrive >= 'a' && *szDrive <= 'z' )
fResult = hb_fsIsDrv( *szDrive - 'a' );
}
hb_retl( fResult );
}
HB_FUNC( DISKCHANGE )
{
hb_retl( ( ISCHAR( 1 ) && hb_parclen( 1 ) > 0 ) ?
hb_fsChDrv( ( BYTE )( toupper( *hb_parc( 1 ) ) - 'A' ) ) == 0 :
FALSE );
BOOL fResult = FALSE;
char * szDrive = hb_parc( 1 );
if( szDrive )
{
if( *szDrive >= 'A' && *szDrive <= 'Z' )
fResult = hb_fsChDrv( *szDrive - 'A' );
else if( *szDrive >= 'a' && *szDrive <= 'z' )
fResult = hb_fsChDrv( *szDrive - 'a' );
}
hb_retl( fResult );
}
HB_FUNC( DISKNAME )
{
#if defined(HB_OS_HAS_DRIVE_LETTER)
char szDrive[ 1 ];
szDrive[ 0 ] = ( ( char ) hb_fsCurDrv() ) + 'A';
hb_retclen( szDrive, 1 );
#else
hb_retc_null();
#endif
}
#endif

View File

@@ -2730,6 +2730,31 @@ USHORT hb_fsChDrv( BYTE nDrive )
/* NOTE: 0=A:, 1=B:, 2=C:, 3=D:, ... */
BYTE hb_fsCurDrv( void )
{
UINT uiResult;
HB_TRACE(HB_TR_DEBUG, ("hb_fsCurDrv()"));
#if defined(HB_OS_HAS_DRIVE_LETTER)
hb_vmUnlock();
HB_FS_GETDRIVE( uiResult );
hb_fsSetError( 0 );
hb_vmLock();
#else
uiResult = 0;
hb_fsSetError( ( USHORT ) FS_ERROR );
#endif
return ( BYTE ) uiResult; /* Return the drive number, base 0. */
}
/* NOTE: 0=A:, 1=B:, 2=C:, 3=D:, ... */
/* TOFIX: This isn't fully compliant because CA-Cl*pper doesn't access
the drive before checking. hb_fsIsDrv only returns TRUE
if there is a disk in the drive. */
@@ -2827,30 +2852,6 @@ BOOL hb_fsIsDevice( HB_FHANDLE hFileHandle )
return bResult;
}
/* NOTE: 0=A:, 1=B:, 2=C:, 3=D:, ... */
BYTE hb_fsCurDrv( void )
{
UINT uiResult;
HB_TRACE(HB_TR_DEBUG, ("hb_fsCurDrv()"));
#if defined(HB_OS_HAS_DRIVE_LETTER)
hb_vmUnlock();
HB_FS_GETDRIVE( uiResult );
hb_vmLock();
#else
uiResult = 0;
hb_fsSetError( ( USHORT ) FS_ERROR );
#endif
return ( BYTE ) uiResult; /* Return the drive number, base 0. */
}
/* convert file name for hb_fsExtOpen
* caller must free the returned buffer
*/

View File

@@ -73,9 +73,9 @@
# include <io.h>
# include <process.h>
# include <fcntl.h>
#if defined( HB_OS_OS2 )
# include <sys/wait.h>
#endif
# if defined( HB_OS_OS2 )
# include <sys/wait.h>
# endif
#endif
#if defined( HB_OS_OS2 ) || defined( HB_OS_UNIX ) || \

View File

@@ -273,9 +273,18 @@ HB_FUNC( FREADSTR )
HB_FUNC( CURDIR )
{
BYTE byBuffer[ _POSIX_PATH_MAX + 1 ];
USHORT uiDrive = 0;
char * szDrive;
hb_fsCurDirBuff( ( ISCHAR( 1 ) && hb_parclen( 1 ) > 0 ) ?
( USHORT )( toupper( *hb_parc( 1 ) ) - 'A' + 1 ) : 0, byBuffer, sizeof( byBuffer ) );
szDrive = hb_parc( 1 );
if( szDrive )
{
if( *szDrive >= 'A' && *szDrive <= 'Z' )
uiDrive = *szDrive - ( 'A' - 1 );
else if( *szDrive >= 'a' && *szDrive <= 'z' )
uiDrive = *szDrive - ( 'a' - 1 );
}
hb_fsCurDirBuff( uiDrive, byBuffer, sizeof( byBuffer ) );
hb_retc( ( char * ) byBuffer );
}

View File

@@ -62,21 +62,37 @@
HB_FUNC( CURDRIVE )
{
char szDrive[ 1 ];
#if defined(HB_OS_HAS_DRIVE_LETTER)
char szCurDrive[ 1 ], szDrive;
szDrive[ 0 ] = ( ( char ) hb_fsCurDrv() ) + 'A';
hb_retclen( szDrive, 1 );
szCurDrive[ 0 ] = ( ( char ) hb_fsCurDrv() ) + 'A';
hb_retclen( szCurDrive, 1 );
if( ISCHAR( 1 ) && hb_parclen( 1 ) > 0 )
szDrive = hb_parc( 1 );
if( szDrive )
{
while( hb_fsChDrv( ( BYTE )( toupper( *hb_parc( 1 ) ) - 'A' ) ) != 0 )
{
USHORT uiAction = hb_errRT_BASE_Ext1( EG_OPEN, 6001, "Operating system error", HB_ERR_FUNCNAME, 0, EF_CANDEFAULT | EF_CANRETRY, HB_ERR_ARGS_BASEPARAMS );
int iDrive = -1;
if( uiAction != E_RETRY )
break;
if( *szDrive >= 'A' && *szDrive <= 'Z' )
iDrive = *szDrive - 'A';
else if( *szDrive >= 'a' && *szDrive <= 'z' )
iDrive = *szDrive - 'a';
if( iDrive >= 0 )
{
while( hb_fsChDrv( ( BYTE ) iDrive ) != 0 )
{
USHORT uiAction = hb_errRT_BASE_Ext1( EG_OPEN, 6001, "Operating system error",
HB_ERR_FUNCNAME, 0, EF_CANDEFAULT | EF_CANRETRY,
HB_ERR_ARGS_BASEPARAMS );
if( uiAction != E_RETRY )
break;
}
}
}
#else
hb_retc_null();
#endif
}
#endif