]> granicus.if.org Git - transmission/commitdiff
(trunk libT) #3975 "tr_bencToFile() contains unnecessary calls to stat() and unlink...
authorJordan Lee <jordan@transmissionbt.com>
Sun, 6 Feb 2011 18:56:44 +0000 (18:56 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Sun, 6 Feb 2011 18:56:44 +0000 (18:56 +0000)
remove() doesn't have the same behavior on Windows. On that platform, we should use MoveFileEx( oldpath, newpath, MOVEFILE_REPLACE_EXISTING )." Thanks to rb07 for testing & confirming the fix.

libtransmission/bencode.c

index 280f31cab6fba72920a8968a2425b843f5b66adc..30edb373d1c6708e4945314ad975547d08f0fcf8 100644 (file)
@@ -1707,7 +1707,11 @@ tr_bencToFile( const tr_benc * top, tr_fmt_mode mode, const char * filename )
             tr_fsync( fd );
             tr_close_file( fd );
 
+#ifdef WIN32
+            if( MoveFileEx( tmp, filename, MOVEFILE_REPLACE_EXISTING ) )
+#else
             if( !rename( tmp, filename ) )
+#endif
             {
                 tr_inf( _( "Saved \"%s\"" ), filename );
             }