source rewind reenables sniff mode

so you can rewind most sources after reading (though not pipes)
This commit is contained in:
John Cupitt 2021-01-21 14:30:46 +00:00
parent 179e9d1a11
commit a7acdf567c
2 changed files with 11 additions and 3 deletions

View File

@ -260,7 +260,7 @@ vips_foreign_load_openslide_class_init( VipsForeignLoadOpenslideClass *class )
VIPS_ARG_BOOL( class, "attach-associated", 13,
_( "Attach associated" ),
_( "Attach all asssociated images" ),
_( "Attach all associated images" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadOpenslide, attach_associated ),
FALSE );

View File

@ -1159,8 +1159,10 @@ vips_source_seek( VipsSource *source, gint64 offset, int whence )
* vips_source_rewind:
* @source: source to operate on
*
* Rewind the source to the start. You can't do this after pixel decode phase
* starts.
* Rewind the source to the start.
*
* You can't always do this after the pixel decode phase starts -- for
* example, pipe-like sources can't be rewound.
*
* Returns: 0 on success, or -1 on error.
*/
@ -1175,6 +1177,12 @@ vips_source_rewind( VipsSource *source )
vips_source_seek( source, 0, SEEK_SET ) != 0 )
return( -1 );
/* Back into sniff + header decode state.
*/
source->decode = FALSE;
if( !source->sniff )
source->sniff = g_byte_array_new();
SANITY( source );
return( 0 );