force binary mode for connections on win
stdin / stdout (for example) are created in text mode by default on win. We need to flip them to binary mode for connection read and write. See https://stackoverflow.com/questions/65014352/pipe-libvips-cli-output-to-stdout-in-windows
This commit is contained in:
parent
eddc99e6d8
commit
acc579cc9d
|
@ -12,6 +12,7 @@
|
|||
- block zero width or height images from imagemagick load [Koen1999]
|
||||
- check for overflow in gifload height [lovell]
|
||||
- fix msb_first default in ppm load and save [ewelot]
|
||||
- force binary mode on win for connection read / write [Alreiber]
|
||||
|
||||
6/9/20 started 8.10.2
|
||||
- update magicksave/load profile handling [kelilevi]
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
* - add vips_pipe_read_limit_set()
|
||||
* 3/10/20
|
||||
* - improve behaviour with read and seek on pipes
|
||||
* 26/11/20
|
||||
* - use _setmode() on win to force binary read for previously opened
|
||||
* descriptors
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -62,6 +65,9 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#ifdef OS_WIN32
|
||||
#include <io.h>
|
||||
#endif /*OS_WIN32*/
|
||||
|
||||
#include <vips/vips.h>
|
||||
#include <vips/internal.h>
|
||||
|
@ -300,6 +306,13 @@ vips_source_build( VipsObject *object )
|
|||
if( vips_object_argument_isset( object, "descriptor" ) ) {
|
||||
connection->descriptor = dup( connection->descriptor );
|
||||
connection->close_descriptor = connection->descriptor;
|
||||
|
||||
#ifdef OS_WIN32
|
||||
/* Windows will create eg. stdin and stdout in text mode.
|
||||
* We always read in binary mode.
|
||||
*/
|
||||
_setmode( connection->descriptor, _O_BINARY );
|
||||
#endif /*OS_WIN32*/
|
||||
}
|
||||
|
||||
if( vips_object_argument_isset( object, "blob" ) ) {
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
* socket, node.js stream, etc.
|
||||
*
|
||||
* J.Cupitt, 19/6/14
|
||||
*
|
||||
* 26/11/20
|
||||
* - use _setmode() on win to force binary write for previously opened
|
||||
* descriptors
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -51,6 +55,9 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#ifdef OS_WIN32
|
||||
#include <io.h>
|
||||
#endif /*OS_WIN32*/
|
||||
|
||||
#include <vips/vips.h>
|
||||
#include <vips/internal.h>
|
||||
|
@ -135,10 +142,16 @@ vips_target_build( VipsObject *object )
|
|||
else if( vips_object_argument_isset( object, "descriptor" ) ) {
|
||||
connection->descriptor = dup( connection->descriptor );
|
||||
connection->close_descriptor = connection->descriptor;
|
||||
|
||||
#ifdef OS_WIN32
|
||||
/* Windows will create eg. stdin and stdout in text mode.
|
||||
* We always write in binary mode.
|
||||
*/
|
||||
_setmode( connection->descriptor, _O_BINARY );
|
||||
#endif /*OS_WIN32*/
|
||||
}
|
||||
else if( target->memory ) {
|
||||
else if( target->memory )
|
||||
target->memory_buffer = g_byte_array_new();
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue