]> git.sesse.net Git - vlc/blobdiff - src/config/file.c
Fix use of --data-path
[vlc] / src / config / file.c
index 67708937232691302d851fcf2559632b7ae1bd75..db1128dc266597eada44da777a956e3e3393ef18 100644 (file)
@@ -32,7 +32,7 @@
 #include <sys/stat.h>
 #ifdef __APPLE__
 #   include <xlocale.h>
-#else
+#elif defined(HAVE_USELOCALE)
 #include <locale.h>
 #endif
 
@@ -54,7 +54,8 @@ static inline char *strdupnull (const char *src)
  */
 static char *config_GetConfigFile( vlc_object_t *obj )
 {
-    char *psz_file = config_GetPsz( obj, "config" );
+    char *psz_file = var_CreateGetNonEmptyString( obj, "config" );
+    var_Destroy( obj, "config" );
     if( psz_file == NULL )
     {
         char *psz_dir = config_GetUserDir( VLC_CONFIG_DIR );
@@ -119,7 +120,8 @@ static FILE *config_OpenConfigFile( vlc_object_t *p_obj )
                     free( psz_readme );
                 }
                 /* Remove the old configuration file so that --reset-config
-                 * can work properly. */
+                 * can work properly. Fortunately, Linux allows removing
+                 * open files - with most filesystems. */
                 unlink( psz_old );
             }
             free( psz_old );
@@ -683,7 +685,11 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
      */
     fflush (file); /* Flush from run-time */
 #ifndef WIN32
+#ifdef __APPLE__
+    fsync (fd); /* Flush from OS */
+#else
     fdatasync (fd); /* Flush from OS */
+#endif
     /* Atomically replace the file... */
     if (utf8_rename (temporary, permanent))
         utf8_unlink (temporary);