1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-20 04:41:36 +02:00

* Added support for complex filenames with Taglib.

This commit is contained in:
Christian Muehlhaeuser
2011-02-10 11:18:59 +01:00
parent 9baa54870e
commit 902326bf2a
4 changed files with 28 additions and 4 deletions

View File

@@ -14,6 +14,9 @@ ELSE()
ENDIF()
FIND_PACKAGE( Taglib 1.6.0 REQUIRED )
include( CheckTagLibFileName )
check_taglib_filename( COMPLEX_TAGLIB_FILENAME )
FIND_PACKAGE( LibLastFm 0.3.3 REQUIRED )
FIND_PACKAGE( LibEchonest 1.1.1 REQUIRED )
FIND_PACKAGE( CLucene REQUIRED )
@@ -29,4 +32,3 @@ ADD_SUBDIRECTORY( libportfwd )
ADD_SUBDIRECTORY( qxt )
ADD_SUBDIRECTORY( src/libtomahawk )
ADD_SUBDIRECTORY( src )

View File

@@ -0,0 +1,15 @@
# taglib changed filenames to be a char/wchar struct on some platforms, need to check for it
macro (CHECK_TAGLIB_FILENAME TAGLIB_FILENAME_COMPLEX)
include (CheckCXXSourceCompiles)
set (CMAKE_REQUIRED_FLAGS ${TAGLIB_CFLAGS})
set (CMAKE_REQUIRED_INCLUDES ${TAGLIB_INCLUDES})
set (CMAKE_REQUIRED_LIBRARIES ${TAGLIB_LIBRARIES})
check_cxx_source_compiles(
"#include <tfile.h>
int main()
{
TagLib::FileName fileName1(\"char\");
TagLib::FileName fileName2(L\"wchar\");
return 0;
}" ${TAGLIB_FILENAME_COMPLEX})
endmacro (CHECK_TAGLIB_FILENAME)

View File

@@ -1,6 +1,6 @@
#ifndef RESULT_H
#define RESULT_H
#include <qvariant.h>
#include <QObject>

View File

@@ -160,7 +160,14 @@ MusicScanner::readFile( const QFileInfo& fi )
if( m_scanned % 100 == 0 )
qDebug() << "SCAN" << m_scanned << fi.absoluteFilePath();
TagLib::FileRef f( fi.absoluteFilePath().toUtf8().constData() );
#ifdef COMPLEX_TAGLIB_FILENAME
const wchar_t *encodedName = reinterpret_cast< const wchar_t *>(fi.absoluteFilePath().utf16());
#else
QByteArray fileName = QFile::encodeName( fi.absoluteFilePath() );
const char *encodedName = fileName.constData();
#endif
TagLib::FileRef f( encodedName );
if ( f.isNull() || !f.tag() )
{
// qDebug() << "Doesn't seem to be a valid audiofile:" << fi.absoluteFilePath();