[vlc-devel] commit: taglib: Fix opening of filenames on non-UTF8 systems. ( Derk-Jan Hartman )
git version control
git at videolan.org
Sun Aug 17 18:10:51 CEST 2008
vlc | branch: master | Derk-Jan Hartman <hartman at veda.student.utwente.nl> | Sun Aug 17 18:12:27 2008 +0200| [1728429512a7bf0fec3b46480178e6cf59bb0000] | committer: Derk-Jan Hartman
taglib: Fix opening of filenames on non-UTF8 systems.
Unfortunately taglib does not accept fd's or FILE*, so i ported the code from src/text/unicode.c open() to here.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1728429512a7bf0fec3b46480178e6cf59bb0000
---
modules/meta_engine/taglib.cpp | 32 +++++++++++++++++++++++++++++++-
1 files changed, 31 insertions(+), 1 deletions(-)
diff --git a/modules/meta_engine/taglib.cpp b/modules/meta_engine/taglib.cpp
index 67e54dd..1845f6f 100644
--- a/modules/meta_engine/taglib.cpp
+++ b/modules/meta_engine/taglib.cpp
@@ -32,6 +32,13 @@
#include <vlc_meta.h>
#include <vlc_demux.h>
#include <vlc_strings.h>
+#include <vlc_charset.h>
+
+#ifdef WIN32
+# include <io.h>
+#else
+# include <unistd.h>
+#endif
#include <fileref.h>
#include <tag.h>
@@ -242,7 +249,30 @@ static int ReadMeta( vlc_object_t *p_this )
TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments );
p_demux_meta->p_meta = NULL;
- FileRef f( p_demux->psz_path );
+#if defined(WIN32) || defined (UNDER_CE)
+ if(GetVersion() < 0x80000000)
+ {
+ wchar_t wpath[MAX_PATH + 1];
+ if( !MultiByteToWideChar( CP_UTF8, 0, p_demux->psz_path, -1, wpath, MAX_PATH) )
+ {
+ errno = ENOENT;
+ return VLC_EGENERIC;
+ }
+ wpath[MAX_PATH] = L'0';
+ FileRef f( wpath );
+ }
+ else return VLC_EGENERIC;
+#else
+ const char *local_name = ToLocale( p_demux->psz_path );
+
+ if( local_name == NULL )
+ {
+ return VLC_EGENERIC;
+ }
+ FileRef f( local_name );
+ LocaleFree( local_name );
+#endif
+
if( f.isNull() )
return VLC_EGENERIC;
More information about the vlc-devel
mailing list