Move descriptor test to vips_source_seek_real

Since subclasses could override the seek method without setting the file descriptor.
This commit is contained in:
Kleis Auke Wolthuizen 2020-12-22 13:34:14 +01:00
parent 2eeeedc957
commit e437805fc1
1 changed files with 4 additions and 6 deletions

View File

@ -153,8 +153,7 @@ vips_source_test_features( VipsSource *source )
* vips_source_seek() etc. or we might trigger seek emulation.
*/
if( source->data ||
(VIPS_CONNECTION( source )->descriptor != -1 &&
class->seek( source, 0, SEEK_CUR ) != -1) ) {
class->seek( source, 0, SEEK_CUR ) != -1 ) {
gint64 length;
VIPS_DEBUG_MSG( " seekable source\n" );
@ -349,16 +348,15 @@ vips_source_seek_real( VipsSource *source, gint64 offset, int whence )
{
VipsConnection *connection = VIPS_CONNECTION( source );
gint64 new_pos;
VIPS_DEBUG_MSG( "vips_source_seek_real:\n" );
/* Like _read_real(), we must not set a vips_error. We need to use the
* vips__seek() wrapper so we can seek long files on Windows.
*/
new_pos = vips__seek_no_error( connection->descriptor, offset, whence );
if( connection->descriptor != -1 )
return( vips__seek_no_error( connection->descriptor, offset, whence ) );
return( new_pos );
return( -1 );
}
static void