]> git.sesse.net Git - vlc/commitdiff
addons: fstorage: close fd before renaming.
authorFrancois Cartegnie <fcvlcdev@free.fr>
Fri, 14 Feb 2014 10:07:08 +0000 (11:07 +0100)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Fri, 14 Feb 2014 10:07:08 +0000 (11:07 +0100)
win32 can't rename a still open fd

modules/misc/addons/fsstorage.c

index 040fcf5008198b9e27c465f089ceaf4e54e114e9..fcc3df7919b9a4b8594f27da8941a49775ff4692 100644 (file)
@@ -637,13 +637,21 @@ static int WriteCatalog( addons_storage_t *p_storage,
         vlc_mutex_unlock( &p_entry->lock );
     }
 
-    vlc_rename( psz_file_tmp, psz_file );
-    free( psz_file );
-    free( psz_file_tmp );
-
     fprintf( p_catalog, "\t</addons>\n" );
     fprintf( p_catalog, "</videolan>\n" );
     fclose( p_catalog );
+
+    int i_ret = vlc_rename( psz_file_tmp, psz_file );
+    free( psz_file );
+    free( psz_file_tmp );
+
+    if( i_ret == -1 )
+    {
+        msg_Err( p_storage, "could not rename %s: %s",
+                 psz_file_tmp, vlc_strerror_c(errno) );
+        return VLC_EGENERIC;
+    }
+
     return VLC_SUCCESS;
 }