See ChangeLog entry 19991106-01:30 EDT David G. Holm <dholm@jsd-llc.com>

This commit is contained in:
David G. Holm
1999-11-06 06:38:46 +00:00
parent 019d2f1dd9
commit 4697c94c60
3 changed files with 28 additions and 17 deletions

View File

@@ -1,3 +1,10 @@
19991106-01:30 EDT David G. Holm <dholm@jsd-llc.com>
* include/filesys.h
* source/rtl/filesys.c
! Proper optimization implemented for hb_fsReadLarge() and
hb_fsWriteLarge(), as suggested by Victor Szel.
19991105-23:30 EDT David G. Holm <dholm@jsd-llc.com>
* source/rtl/filesys.c

View File

@@ -105,6 +105,7 @@ extern BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart,
extern BOOL hb_fsMkDir ( BYTE * pDirName );
extern FHANDLE hb_fsOpen ( BYTE * pFilename, USHORT uiFlags );
extern USHORT hb_fsRead ( FHANDLE hFileHandle, BYTE * pBuff, USHORT ulCount );
extern ULONG hb_fsReadLarge ( FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount );
extern BOOL hb_fsRmDir ( BYTE * pDirName );
extern int hb_fsRename ( BYTE * pOldName, BYTE * pNewName );
extern ULONG hb_fsSeek ( FHANDLE hFileHandle, LONG lOffset, USHORT uiMode );
@@ -114,17 +115,7 @@ extern void hb_fsSetDevRaw ( FHANDLE hFileHandle );
extern void hb_fsSetDevText ( FHANDLE hFileHandle );
extern void hb_fsSetError ( USHORT uiError );
extern USHORT hb_fsWrite ( FHANDLE hFileHandle, BYTE * pBuff, USHORT ulCount );
#if UINT_MAX == ULONG_MAX
/* NOTE: hb_fsRead/hb_fsWrite can work with ULONG data blocks */
#define hb_fsReadLarge hb_fsRead
#define hb_fsWriteLarge hb_fsWrite
#else
/* NOTE: otherwise, the extended version of the functions
will be used to copy and/or set ULONG data blocks */
extern ULONG hb_fsReadLarge ( FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount );
extern ULONG hb_fsWriteLarge ( FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount );
#endif
extern PHB_FNAME hb_fsFNameSplit ( char * szFilename ); /* Split given filename into path, name and extension */
extern char * hb_fsFNameMerge ( char * szFileName, PHB_FNAME pFileName ); /* This function joins path, name and extension into a string with a filename */

View File

@@ -208,6 +208,12 @@ static USHORT s_uiErrorLast = 0;
#define PATH_MAX 256
#endif
#if UINT_MAX == ULONG_MAX
#define HB_FS_LARGE_OPTIMIZED
#else
#define LARGE_MAX ( UINT_MAX - 1L )
#endif
extern int rename( const char *, const char * );
/* Convert HARBOUR flags to IO subsystem flags */
@@ -558,23 +564,24 @@ USHORT hb_fsWrite( FHANDLE hFileHandle, BYTE * pBuff, USHORT uiCount )
return uiWritten;
}
#if UINT_MAX != ULONG_MAX
#define LARGE_MAX ( UINT_MAX - 1L )
ULONG hb_fsReadLarge( FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount )
{
ULONG ulRead = 0;
#if ! defined(HB_FS_LARGE_OPTIMIZED)
ULONG ulLeftToRead = ulCount;
USHORT uiToRead;
USHORT uiRead;
BYTE * pPtr = pBuff;
#endif
HB_TRACE(HB_TR_DEBUG, ("hb_fsReadLarge(%p, %p, %lu)", hFileHandle, pBuff, ulCount));
#if defined(HAVE_POSIX_IO) || defined(_MSC_VER) || defined(__MINGW32__)
errno = 0;
#if defined(HB_FS_LARGE_OPTIMIZED)
ulRead = read( hFileHandle, pBuff, ulCount );
#else
while( ulLeftToRead )
{
/* Determine how much to read this time */
@@ -598,6 +605,7 @@ ULONG hb_fsReadLarge( FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount )
ulRead += ( ULONG ) uiRead;
pPtr += uiRead;
}
#endif
s_uiErrorLast = errno;
#else
@@ -612,17 +620,23 @@ ULONG hb_fsReadLarge( FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount )
ULONG hb_fsWriteLarge( FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount )
{
ULONG ulWritten = 0;
#if ! defined(HB_FS_LARGE_OPTIMIZED)
ULONG ulLeftToWrite = ulCount;
USHORT uiToWrite;
USHORT uiWritten;
BYTE * pPtr = pBuff;
#endif
HB_TRACE(HB_TR_DEBUG, ("hb_fsWriteLarge(%p, %p, %lu)", hFileHandle, pBuff, ulCount));
#if defined(HAVE_POSIX_IO) || defined(_MSC_VER) || defined(__MINGW32__)
errno = 0;
if( ulCount ) while( ulLeftToWrite )
if( ulCount )
#if defined(HB_FS_LARGE_OPTIMIZED)
ulWritten = write( hFileHandle, pBuff, ulCount );
#else
while( ulLeftToWrite )
{
/* Determine how much to write this time */
if( ulLeftToWrite > ( ULONG ) INT_MAX )
@@ -645,6 +659,7 @@ ULONG hb_fsWriteLarge( FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount )
ulWritten += ( ULONG ) uiWritten;
pPtr += uiWritten;
}
#endif
else ftruncate( hFileHandle, tell( hFileHandle ) );
s_uiErrorLast = errno;
@@ -657,8 +672,6 @@ ULONG hb_fsWriteLarge( FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount )
return ulWritten;
}
#endif
ULONG hb_fsSeek( FHANDLE hFileHandle, LONG lOffset, USHORT uiFlags )
{
ULONG ulPos;