test descriptor properties
This commit is contained in:
parent
c01c3b9100
commit
9ea5e902b6
@ -146,10 +146,6 @@ typedef struct _VipsStreamInput {
|
||||
*/
|
||||
VipsBlob *blob;
|
||||
|
||||
/* Set on EOF.
|
||||
*/
|
||||
gboolean eof;
|
||||
|
||||
} VipsStreamInput;
|
||||
|
||||
typedef struct _VipsStreamInputClass {
|
||||
@ -185,7 +181,6 @@ ssize_t vips_stream_input_read( VipsStreamInput *input,
|
||||
int vips_stream_input_rewind( VipsStreamInput *input );
|
||||
void vips_stream_input_minimise( VipsStreamInput *input );
|
||||
void vips_stream_input_decode( VipsStreamInput *input );
|
||||
gboolean vips_stream_input_eof( VipsStreamInput *input );
|
||||
unsigned char *vips_stream_input_sniff( VipsStreamInput *input, size_t length );
|
||||
|
||||
#define VIPS_TYPE_STREAM_OUTPUT (vips_stream_output_get_type())
|
||||
|
@ -33,15 +33,10 @@
|
||||
|
||||
/* TODO
|
||||
*
|
||||
* - minimise support, and reenable jpg test_descriptors
|
||||
* - filename encoding
|
||||
* - memory output
|
||||
* - add mmapable descriptors
|
||||
* - add seekable descriptors
|
||||
* - can we test for mmapable and seekable?
|
||||
* - do we need eof?
|
||||
* - need a close() vfunc? output is a bit ugly, and node streams might need
|
||||
* it
|
||||
* - test for mmapable
|
||||
* - can we really change all behaviour in the subclass? will we need map and
|
||||
* seek as well as read and rewind?
|
||||
*/
|
||||
@ -219,7 +214,6 @@ vips_stream_input_open( VipsStreamInput *input )
|
||||
|
||||
stream->tracked_descriptor = fd;
|
||||
stream->descriptor = fd;
|
||||
input->seekable = TRUE;
|
||||
|
||||
VIPS_DEBUG_MSG( "vips_stream_input_open: "
|
||||
"restoring read position %zd\n", input->read_position );
|
||||
@ -262,6 +256,16 @@ vips_stream_input_build( VipsObject *object )
|
||||
stream->close_descriptor = stream->descriptor;
|
||||
}
|
||||
|
||||
/* If there's a descriptor for input, test its properties.
|
||||
*/
|
||||
if( stream->descriptor != -1 ) {
|
||||
/* Do +=0 on the current position. This fails for pipes, at
|
||||
* least on linux.
|
||||
*/
|
||||
if( lseek( stream->descriptor, 0, SEEK_CUR ) != -1 )
|
||||
input->seekable = TRUE;
|
||||
}
|
||||
|
||||
if( vips_object_argument_isset( object, "blob" ) )
|
||||
input->seekable = TRUE;
|
||||
|
||||
@ -340,7 +344,6 @@ vips_stream_input_rewind_real( VipsStreamInput *input )
|
||||
}
|
||||
|
||||
input->read_position = 0;
|
||||
input->eof = FALSE;
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
@ -382,13 +385,6 @@ vips_stream_input_class_init( VipsStreamInputClass *class )
|
||||
G_STRUCT_OFFSET( VipsStreamInput, blob ),
|
||||
VIPS_TYPE_BLOB );
|
||||
|
||||
VIPS_ARG_BOOL( class, "seekable", 4,
|
||||
_( "Seekable" ),
|
||||
_( "'descriptor' supports lseek()" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsStreamInput, seekable ),
|
||||
FALSE );
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
@ -582,8 +578,6 @@ vips_stream_input_read( VipsStreamInput *input,
|
||||
"%s", _( "read error" ) );
|
||||
return( -1 );
|
||||
}
|
||||
if( n == 0 )
|
||||
input->eof = TRUE;
|
||||
|
||||
/* If we're not seekable, we need to save header bytes for
|
||||
* reuse.
|
||||
@ -624,14 +618,6 @@ vips_stream_input_minimise( VipsStreamInput *input )
|
||||
class->minimise( input );
|
||||
}
|
||||
|
||||
gboolean
|
||||
vips_stream_input_eof( VipsStreamInput *input )
|
||||
{
|
||||
VIPS_DEBUG_MSG( "vips_stream_input_eof:\n" );
|
||||
|
||||
return( input->eof );
|
||||
}
|
||||
|
||||
void
|
||||
vips_stream_input_decode( VipsStreamInput *input )
|
||||
{
|
||||
|
@ -727,8 +727,11 @@ vips__file_read( FILE *fp, const char *filename, size_t *length_out )
|
||||
do {
|
||||
char *str2;
|
||||
|
||||
/* Again, a 1gb sanity limit.
|
||||
*/
|
||||
size += 1024;
|
||||
if( !(str2 = realloc( str, size )) ) {
|
||||
if( size > 1024 * 1024 * 1024 ||
|
||||
!(str2 = realloc( str, size )) ) {
|
||||
free( str );
|
||||
vips_error( "vips__file_read",
|
||||
"%s", _( "out of memory" ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user