]> git.sesse.net Git - vlc/blobdiff - modules/access_filter/timeshift.c
All: missing #include "charset.h"
[vlc] / modules / access_filter / timeshift.c
index aa35a6050609fbfc4054a3c370ecb88e34dde9a4..361534fcce7c089ed787f258ebe94d165fb58996 100644 (file)
@@ -31,6 +31,8 @@
 
 #include <vlc/vlc.h>
 #include <vlc/input.h>
+#include "charset.h"
+
 #include <unistd.h>
 
 /*****************************************************************************
@@ -375,7 +377,7 @@ static int WriteBlockToFile( access_t *p_access, block_t *p_block )
 
         sprintf( p_sys->psz_filename, "%s%i.dat",
                  p_sys->psz_filename_base, p_sys->i_files );
-        file = fopen( p_sys->psz_filename, "w+b" );
+        file = utf8_fopen( p_sys->psz_filename, "w+b" );
 
         if( !file && p_sys->i_files < 2 )
         {
@@ -535,35 +537,38 @@ static char *GetTmpFilePath( access_t *p_access )
     char *psz_dir = var_GetString( p_access, "timeshift-dir" );
     char *psz_filename_base;
 
-    if( psz_dir && !*psz_dir )
+    if( ( psz_dir != NULL ) && ( psz_dir[0] == '\0' ) )
     {
         free( psz_dir );
-        psz_dir = 0;
+        psz_dir = NULL;
     }
 
-    if( !psz_dir )
+    if( psz_dir == NULL )
     {
 #ifdef WIN32
+        char psz_local_dir[MAX_PATH];
         int i_size;
 
-        psz_dir = malloc( MAX_PATH + 1 );
-        i_size = GetTempPath( MAX_PATH, psz_dir );
+        i_size = GetTempPath( MAX_PATH, psz_local_dir );
         if( i_size <= 0 || i_size > MAX_PATH )
         {
-            if( !getcwd( psz_dir, MAX_PATH ) ) strcpy( psz_dir, "c:" );
+            if( !getcwd( psz_local_dir, MAX_PATH ) )
+                strcpy( psz_local_dir, "C:" );
         }
 
+        psz_dir = FromLocaleDup( psz_local_dir );
+
         /* remove last \\ if any */
         if( psz_dir[strlen(psz_dir)-1] == '\\' )
             psz_dir[strlen(psz_dir)-1] = '\0';
 #else
-
         psz_dir = strdup( "/tmp" );
 #endif
     }
 
     asprintf( &psz_filename_base, "%s/vlc-timeshift-%d-%d-",
               psz_dir, getpid(), p_access->i_object_id );
+    free( psz_dir );
 
     return psz_filename_base;
 }