fix temp file open
was not auto-deleteing on windows, needs a fallback on linux see https://github.com/libvips/libvips/pull/1155
This commit is contained in:
parent
1b47c64c94
commit
0bea76d364
@ -1,6 +1,7 @@
|
|||||||
23/9/18 started 8.7.1
|
23/9/18 started 8.7.1
|
||||||
- update function list in docs [janko-m]
|
- update function list in docs [janko-m]
|
||||||
- test for g_str_to_ascii() [jcupitt]
|
- test for g_str_to_ascii() [jcupitt]
|
||||||
|
- fix temp file open on Windows and fallback on linux [lovell]
|
||||||
|
|
||||||
23/12/17 started 8.7.0
|
23/12/17 started 8.7.0
|
||||||
- add magicksave, save image with libMagick [dlemstra]
|
- add magicksave, save image with libMagick [dlemstra]
|
||||||
|
@ -187,37 +187,37 @@ vips__open_image_write( const char *filename, gboolean temp )
|
|||||||
int flags;
|
int flags;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
flags = MODE_WRITE;
|
fd = -1;
|
||||||
|
|
||||||
#ifdef O_TMPFILE
|
#ifdef O_TMPFILE
|
||||||
/* Linux-only extension creates an unlinked file. CREAT and TRUNC must
|
/* Linux-only extension creates an unlinked file. CREAT and TRUNC must
|
||||||
* be clear. The filename arg to open() must name a directory.
|
* be clear. The filename arg to open() must name a directory.
|
||||||
|
*
|
||||||
|
* This can fail since not all filesystems support it. In this case,
|
||||||
|
* we open as a regular file and rely on the delete-on-close
|
||||||
|
* mechanism, see vips_image_delete().
|
||||||
*/
|
*/
|
||||||
if( temp ) {
|
if( temp ) {
|
||||||
char *dirname;
|
char *dirname;
|
||||||
|
|
||||||
flags |= O_TMPFILE;
|
|
||||||
flags &= ~O_CREAT;
|
|
||||||
flags &= ~O_TRUNC;
|
|
||||||
|
|
||||||
dirname = g_path_get_dirname( filename );
|
dirname = g_path_get_dirname( filename );
|
||||||
fd = vips_tracked_open( dirname, flags, 0666 );
|
fd = vips_tracked_open( dirname, O_TMPFILE | O_RDWR , 0666 );
|
||||||
g_free( dirname );
|
g_free( dirname );
|
||||||
}
|
}
|
||||||
else
|
#endif /*O_TMPFILE*/
|
||||||
fd = vips_tracked_open( filename, flags, 0666 );
|
|
||||||
#else /*!O_TMPFILE*/
|
flags = MODE_WRITE;
|
||||||
fd = vips_tracked_open( filename, flags, 0666 );
|
|
||||||
|
|
||||||
#ifdef _O_TEMPORARY
|
#ifdef _O_TEMPORARY
|
||||||
/* On Windows, setting _O_TEMPORARY gets the file automatically
|
/* On Windows, setting _O_TEMPORARY will delete the file automatically
|
||||||
* deleted on process exit, even if the processes crashes. See
|
* on process exit, even if the processes crashes.
|
||||||
* vips_image_rewind() for what we do to help on *nix.
|
|
||||||
*/
|
*/
|
||||||
if( temp )
|
if( temp )
|
||||||
flags |= _O_TEMPORARY;
|
flags |= _O_TEMPORARY;
|
||||||
#endif /*_O_TEMPORARY*/
|
#endif /*_O_TEMPORARY*/
|
||||||
#endif /*O_TMPFILE*/
|
|
||||||
|
if( fd < 0 )
|
||||||
|
fd = vips_tracked_open( filename, flags, 0666 );
|
||||||
|
|
||||||
if( fd < 0 ) {
|
if( fd < 0 ) {
|
||||||
vips_error_system( errno, "VipsImage",
|
vips_error_system( errno, "VipsImage",
|
||||||
|
Loading…
Reference in New Issue
Block a user