Make flac and ogg transcode and scan properly for unicode filenames.

This commit is contained in:
Ron Pedde 2006-08-11 05:33:54 +00:00
parent 9defe79e42
commit f7cc8ea470
2 changed files with 22 additions and 1 deletions

View File

@ -6,7 +6,9 @@
# include "config.h"
#endif
#undef fopen
#ifdef WIN32
#include <windows.h>
#endif
#include <stdio.h>
#include <stdlib.h>
@ -152,6 +154,10 @@ int ssc_ffmpeg_open(void *vp, char *file, char *codec, int duration) {
int i;
enum CodecID id=CODEC_ID_FLAC;
SSCHANDLE *handle = (SSCHANDLE*)vp;
#ifdef WIN32
WCHAR utf16_path[_MAX_PATH+1];
WCHAR utf16_mode[3];
#endif
if(!handle)
return FALSE;
@ -181,8 +187,18 @@ int ssc_ffmpeg_open(void *vp, char *file, char *codec, int duration) {
return FALSE;
}
#ifdef WIN32
/* this is a mess. the fopen should really be pushed back
* up to the server, so it can handle streams or something.
*/
MultiByteToWideChar(CP_UTF8,0,file,-1,utf16_path,sizeof(utf16_path)/sizeof(utf16_path[0]));
MultiByteToWideChar(CP_ACP,0,"rb",-1,utf16_mode,sizeof(utf16_mode)/sizeof(utf16_mode[0]));
handle->fin = _wfopen(utf16_path, utf16_mode);
#else
handle->fin = fopen(file,"rb");
#endif
if(!handle->fin) {
_ppi->log(E_DBG,"could not open file\n");
handle->errnum = SSC_FFMPEG_E_FILEOPEN;
return FALSE;
}

View File

@ -6,6 +6,11 @@
* Copyright 2002 Michael Smith <msmith@xiph.org>
* Licensed under the GNU GPL, distributed with this program.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>