#ifndef WIN32
fdatasync (fd); /* Flush from OS */
/* Atomically replace the file... */
- utf8_rename (temporary, permanent);
+ if (utf8_rename (temporary, permanent))
+ utf8_unlink (temporary);
/* (...then synchronize the directory, err, TODO...) */
/* ...and finally close the file */
vlc_mutex_unlock (&lock);
#ifdef WIN32
/* Windows cannot remove open files nor overwrite existing ones */
utf8_unlink (permanent);
- utf8_rename (temporary, permanent);
+ if (utf8_rename (temporary, permanent))
+ utf8_unlink (temporary);
vlc_mutex_unlock (&lock);
#endif