add comments re. temp file open bug
This commit is contained in:
parent
e5234287da
commit
89c6d29079
@ -3077,13 +3077,13 @@ vips_image_rewind_output( VipsImage *image )
|
|||||||
/* Now we've finished writing and reopened as read, we can
|
/* Now we've finished writing and reopened as read, we can
|
||||||
* delete-on-close.
|
* delete-on-close.
|
||||||
*
|
*
|
||||||
* On *nix-like systems, this will unlink the file
|
* On *nix-like systems, this will unlink the file from the
|
||||||
* from the filesystem and when we exit, for whatever reason, the file
|
* filesystem and when we exit, for whatever reason, the file
|
||||||
* we be reclaimed.
|
* we be reclaimed.
|
||||||
*
|
*
|
||||||
* On Windows this will fail because the file is open and you can't
|
* On Windows this will fail because the file is open and you can't
|
||||||
* delete open files. However, on Windows we set O_TEMP, so the file
|
* delete open files. However, on Windows we set _O_TEMPORARY, so the
|
||||||
* will be deleted when the fd is finally closed.
|
* file will be deleted when the fd is finally closed.
|
||||||
*/
|
*/
|
||||||
vips_image_delete( image );
|
vips_image_delete( image );
|
||||||
|
|
||||||
|
@ -137,7 +137,6 @@
|
|||||||
*
|
*
|
||||||
* We use O_RDWR not O_WRONLY since after writing we may want to rewind the
|
* We use O_RDWR not O_WRONLY since after writing we may want to rewind the
|
||||||
* image and read from it.
|
* image and read from it.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
#define MODE_WRITE BINARYIZE (O_RDWR | O_CREAT | O_TRUNC)
|
#define MODE_WRITE BINARYIZE (O_RDWR | O_CREAT | O_TRUNC)
|
||||||
|
|
||||||
@ -187,12 +186,15 @@ vips__open_image_write( const char *filename, gboolean temp )
|
|||||||
int flags;
|
int flags;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
flags = MODE_WRITE;
|
|
||||||
fd = -1;
|
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;
|
||||||
@ -203,10 +205,11 @@ vips__open_image_write( const char *filename, gboolean temp )
|
|||||||
}
|
}
|
||||||
#endif /*O_TMPFILE*/
|
#endif /*O_TMPFILE*/
|
||||||
|
|
||||||
|
flags = MODE_WRITE;
|
||||||
|
|
||||||
#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;
|
||||||
|
Loading…
Reference in New Issue
Block a user