2008-11-01 12:02 UTC+0200 Viktor Szakats (harbour.01 syenar hu)

* include/hbextern.ch
  * source/rtl/memofile.c
    + Added HB_MEMOREAD() which is identical to MEMOREAD() 
      except it won't truncate the last byte (on non-UNIX 
      compatible systems) if it's a EOF char.
      See also existing HB_MEMOWRIT().
      [TOMERGE 1.0]
This commit is contained in:
Viktor Szakats
2008-11-01 11:02:57 +00:00
parent e6c3780c1b
commit e226b165e1
3 changed files with 29 additions and 6 deletions

View File

@@ -8,6 +8,15 @@
2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
*/
2008-11-01 12:02 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
* include/hbextern.ch
* source/rtl/memofile.c
+ Added HB_MEMOREAD() which is identical to MEMOREAD()
except it won't truncate the last byte (on non-UNIX
compatible systems) if it's a EOF char.
See also existing HB_MEMOWRIT().
[TOMERGE 1.0]
2008-11-01 11:24 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
* source/rtl/hbi18n.c
* Minor change in header to separate it visually from comment

View File

@@ -1130,6 +1130,7 @@ EXTERNAL HB_TOKENGET
EXTERNAL HB_TOKENPTR
EXTERNAL HB_ATOKENS
EXTERNAL HB_STRSHRINK
EXTERNAL HB_MEMOREAD
EXTERNAL HB_MEMOWRIT
EXTERNAL HB_NTOS

View File

@@ -58,7 +58,7 @@
this limit is extended, so we are not *strictly* compatible here.
[vszakats] */
HB_FUNC( MEMOREAD )
static void hb_memoread( BOOL bHandleEOF )
{
PHB_ITEM pFileName = hb_param( 1, HB_IT_STRING );
@@ -76,7 +76,8 @@ HB_FUNC( MEMOREAD )
/* Don't read the file terminating EOF character */
#if ! defined(HB_OS_UNIX_COMPATIBLE)
#if ! defined(HB_OS_UNIX_COMPATIBLE)
if( bHandleEOF )
{
BYTE byEOF = HB_CHAR_NUL;
@@ -86,7 +87,9 @@ HB_FUNC( MEMOREAD )
if( byEOF == HB_CHAR_EOF )
ulSize--;
}
#endif
#else
HB_SYMBOL_UNUSED( bHandleEOF );
#endif
pbyBuffer = ( BYTE * ) hb_xgrab( ulSize + sizeof( char ) );
@@ -107,7 +110,17 @@ HB_FUNC( MEMOREAD )
hb_retc( NULL );
}
static BOOL hb_memowrit( BOOL bWriteEOF )
HB_FUNC( HB_MEMOREAD )
{
hb_memoread( FALSE );
}
HB_FUNC( MEMOREAD )
{
hb_memoread( TRUE );
}
static BOOL hb_memowrit( BOOL bHandleEOF )
{
PHB_ITEM pFileName = hb_param( 1, HB_IT_STRING );
PHB_ITEM pString = hb_param( 2, HB_IT_STRING );
@@ -126,13 +139,13 @@ static BOOL hb_memowrit( BOOL bWriteEOF )
/* NOTE: CA-Cl*pper will add the EOF even if the write failed. [vszakats] */
/* NOTE: CA-Cl*pper will not return .F. when the EOF could not be written. [vszakats] */
#if ! defined(HB_OS_UNIX_COMPATIBLE)
if( bWriteEOF ) /* if true, then write EOF */
if( bHandleEOF ) /* if true, then write EOF */
{
BYTE byEOF = HB_CHAR_EOF;
hb_fsWrite( fhnd, &byEOF, sizeof( BYTE ) );
}
#else
HB_SYMBOL_UNUSED( bWriteEOF );
HB_SYMBOL_UNUSED( bHandleEOF );
#endif
hb_fsClose( fhnd );