2014-03-20 14:59 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* src/rtl/filesys.c
    ! added workaround for offset returned by FSeek( hDir, 0, FS_END )
      for directories handles in some *nixes
This commit is contained in:
Przemysław Czerpak
2014-03-20 14:59:02 +01:00
parent fc14c595dc
commit 046c9694e0
2 changed files with 29 additions and 4 deletions

View File

@@ -2899,6 +2899,16 @@ HB_ULONG hb_fsSeek( HB_FHANDLE hFileHandle, HB_LONG lOffset, HB_USHORT uiFlags )
{
ulPos = lseek( hFileHandle, lOffset, nFlags );
hb_fsSetIOError( ulPos != ( HB_ULONG ) -1, 0 );
# if defined( HB_OS_UNIX )
/* small trick to resolve problem with position reported for directories */
if( ulPos == LONG_MAX && lOffset == 0 && nFlags == SEEK_END )
{
struct stat st;
if( fstat( hFileHandle, &st ) == 0 )
ulPos = st.st_size;
}
# endif
}
if( ulPos == ( HB_ULONG ) -1 )
@@ -2966,6 +2976,16 @@ HB_FOFFSET hb_fsSeekLarge( HB_FHANDLE hFileHandle, HB_FOFFSET nOffset, HB_USHORT
{
nPos = lseek64( hFileHandle, nOffset, nFlags );
hb_fsSetIOError( nPos != ( HB_FOFFSET ) -1, 0 );
# if defined( HB_OS_UNIX )
/* small trick to resolve problem with position reported for directories */
if( nPos == LONG_MAX && nOffset == 0 && nFlags == SEEK_END )
{
struct stat64 st;
if( fstat64( hFileHandle, &st ) == 0 )
nPos = st.st_size;
}
# endif
}
if( nPos == ( HB_FOFFSET ) -1 )