Commit 5d7f0d78 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

ToLocale -> WideCharToMultiByte (refs #817)

parent de14672a
...@@ -564,21 +564,28 @@ static char *GetTmpFilePath( access_t *p_access ) ...@@ -564,21 +564,28 @@ static char *GetTmpFilePath( access_t *p_access )
if( psz_dir == NULL ) if( psz_dir == NULL )
{ {
#ifdef WIN32 #ifdef WIN32
char psz_local_dir[MAX_PATH]; DWORD ret = GetTempPathW (0, NULL);
int i_size; wchar_t wdir[ret + 3]; // can at least old "C:" + nul
wchar_t *pwdir = wdir, pwdir_free = NULL;
i_size = GetTempPath( MAX_PATH, psz_local_dir ); if (GetTempPathW (ret + 1, wdir) == 0)
if( i_size <= 0 || i_size > MAX_PATH )
{ {
if( !getcwd( psz_local_dir, MAX_PATH ) ) pwdir_free = pwdir = _wgetcwd (NULL, 0);
strcpy( psz_local_dir, "C:" ); if (pwdir == NULL)
wcscpy (wdir, L"C:");
} }
psz_dir = FromLocaleDup( psz_local_dir ); ret = WideCharToMultiByte (CP_UTF8, 0, pwdir, -1, NULL, 0);
char mbdir[ret];
WideCharToMultiByte (CP_UTF8, 0, pwdir, -1, mbdir, ret);
if (pwdir_free != NULL)
free (pwdir_free);
/* remove last \\ if any */ /* remove last \\ if any */
if( psz_dir[strlen(psz_dir)-1] == '\\' ) if (mbdir[strlen (mbdir) - 1] == '\\')
psz_dir[strlen(psz_dir)-1] = '\0'; mbdir[strlen (mbdit) - 1] = '\0';
psz_dir = strdup (mbdir);
#else #else
psz_dir = strdup( "/tmp" ); psz_dir = strdup( "/tmp" );
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment