From 58db3ccf8a73098ab0d7c4ff1227fd497c59e810 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Wed, 26 Aug 2009 11:47:49 +0000 Subject: [PATCH] 2009-08-26 13:47 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rtl/filebuf.c * reverted the alternative IO API look up order * small modification --- harbour/ChangeLog | 5 +++ harbour/source/rtl/filebuf.c | 70 ++++++++++++++++-------------------- 2 files changed, 35 insertions(+), 40 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 4d79548bee..fcd6250392 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,11 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-08-26 13:47 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/rtl/filebuf.c + * reverted the alternative IO API look up order + * small modification + 2009-08-26 13:13 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * config/bsd/gcc.mk * config/darwin/gcc.mk diff --git a/harbour/source/rtl/filebuf.c b/harbour/source/rtl/filebuf.c index be163c370b..accdae7fdd 100644 --- a/harbour/source/rtl/filebuf.c +++ b/harbour/source/rtl/filebuf.c @@ -93,44 +93,12 @@ typedef struct _HB_FILE } HB_FILE; +static const HB_FILE_FUNCS * s_fileMethods( void ); static HB_CRITICAL_NEW( s_fileMtx ); static PHB_FILE s_openFiles = NULL; - -static BOOL s_fileAccept( const char * pFilename ); -static PHB_FILE s_fileExtOpen( const char * pFilename, const char * pDefExt, - USHORT uiExFlags, const char * pPaths, - PHB_ITEM pError ); -static void s_fileClose( PHB_FILE pFile ); -static BOOL s_fileLock( PHB_FILE pFile, HB_FOFFSET ulStart, HB_FOFFSET ulLen, - int iType ); -static ULONG s_fileReadAt( PHB_FILE pFile, void * buffer, ULONG ulSize, - HB_FOFFSET llOffset ); -static ULONG s_fileWriteAt( PHB_FILE pFile, const void * buffer, ULONG ulSize, - HB_FOFFSET llOffset ); -static BOOL s_fileTruncAt( PHB_FILE pFile, HB_FOFFSET llOffset ); -static HB_FOFFSET s_fileSize( PHB_FILE pFile ); -static void s_fileCommit( PHB_FILE pFile ); -static HB_FHANDLE s_fileHandle( PHB_FILE pFile ); - -const HB_FILE_FUNCS s_fileFuncs = -{ - s_fileAccept, - hb_spFileExists, - hb_fsDelete, - s_fileExtOpen, - s_fileClose, - s_fileLock, - s_fileReadAt, - s_fileWriteAt, - s_fileTruncAt, - s_fileSize, - s_fileCommit, - s_fileHandle -}; - /* void hb_fileDsp( PHB_FILE pFile, const char * szMsg ) { @@ -172,7 +140,7 @@ static PHB_FILE hb_fileNew( HB_FHANDLE hFile, BOOL fShared, BOOL fReadonly, { pFile = ( PHB_FILE ) hb_xgrab( sizeof( HB_FILE ) ); memset( pFile, 0, sizeof( HB_FILE ) ); - pFile->pFuncs = &s_fileFuncs; + pFile->pFuncs = s_fileMethods(); pFile->device = device; pFile->inode = inode; pFile->hFile = hFile; @@ -574,6 +542,28 @@ static HB_FHANDLE s_fileHandle( PHB_FILE pFile ) return pFile ? pFile->hFile : FS_ERROR; } +/* methods table */ +const HB_FILE_FUNCS s_fileFuncs = +{ + s_fileAccept, + hb_spFileExists, + hb_fsDelete, + s_fileExtOpen, + s_fileClose, + s_fileLock, + s_fileReadAt, + s_fileWriteAt, + s_fileTruncAt, + s_fileSize, + s_fileCommit, + s_fileHandle +}; + +static const HB_FILE_FUNCS * s_fileMethods( void ) +{ + return &s_fileFuncs; +} + #define HB_FILE_TYPE_MAX 32 @@ -606,9 +596,9 @@ BOOL hb_fileRegister( const HB_FILE_FUNCS * pFuncs ) BOOL hb_fileDelete( const char * pFilename ) { - int i; + int i = s_iFileTypes; - for( i = 0; i < s_iFileTypes; ++i ) + while( --i >= 0 ) { if( s_pFileTypes[ i ]->Accept( pFilename ) ) return s_pFileTypes[ i ]->Delete( pFilename ); @@ -618,9 +608,9 @@ BOOL hb_fileDelete( const char * pFilename ) BOOL hb_fileExists( const char * pFilename, char * pRetPath ) { - int i; + int i = s_iFileTypes; - for( i = 0; i < s_iFileTypes; ++i ) + while( --i >= 0 ) { if( s_pFileTypes[ i ]->Accept( pFilename ) ) return s_pFileTypes[ i ]->Exists( pFilename, pRetPath ); @@ -632,9 +622,9 @@ PHB_FILE hb_fileExtOpen( const char * pFilename, const char * pDefExt, USHORT uiExFlags, const char * pPaths, PHB_ITEM pError ) { - int i; + int i = s_iFileTypes; - for( i = 0; i < s_iFileTypes; ++i ) + while( --i >= 0 ) { if( s_pFileTypes[ i ]->Accept( pFilename ) ) return s_pFileTypes[ i ]->Open( pFilename, pDefExt, uiExFlags, pPaths, pError );