コード例 #1
0
ファイル: parserpls.cpp プロジェクト: Alppasa/mixxx
QString ParserPls::getFilepath(QTextStream *stream, QString basepath)
{
    QString textline,filename = "";
    textline = stream->readLine();
    while (!textline.isEmpty()) {
        if (textline.isNull()) {
            break;
        }

        if(textline.contains("File")) {
            int iPos = textline.indexOf("=",0);
            ++iPos;

            filename = textline.right(textline.length()-iPos);

            //Rythmbox playlists starts with file://<path>
            //We remove the file protocol if found.
            filename.remove("file://");
            QByteArray strlocbytes = filename.toUtf8();
            QUrl location = QUrl::fromEncoded(strlocbytes);
            QString trackLocation = location.toString();
            //qDebug() << trackLocation;

            if(isFilepath(trackLocation)) {
                return trackLocation;
            } else {
                // Try relative to m3u dir
                QString rel = QDir(basepath).filePath(trackLocation);
                if (isFilepath(rel)) {
                    return rel;
                }
                // We couldn't match this to a real file so ignore it
            }
        }
        textline = stream->readLine();
    }

    // Signal we reached the end
    return 0;

}
コード例 #2
0
ファイル: parserm3u.cpp プロジェクト: calabrhoouse/mixxx
QString ParserM3u::getFilepath(QTextStream *stream, QString basepath)
{
    QString textline,filename = "";

    textline = stream->readLine();

    while (!textline.isEmpty()) {
        //qDebug() << "Untransofrmed text: " << textline;
        if (textline.isNull()) {
            break;
        }

        if (!textline.contains("#")) {
            filename = textline;
            filename.remove("file://");
            QByteArray strlocbytes = filename.toUtf8();
            //qDebug() << "QByteArray UTF-8: " << strlocbytes;
            QUrl location = QUrl::fromEncoded(strlocbytes);
            //qDebug() << "QURL UTF-8: " << location;
            QString trackLocation = location.toString();
            //qDebug() << "UTF8 TrackLocation:" << trackLocation;
            if(isFilepath(trackLocation)) {
                return trackLocation;
            } else {
                // Try relative to m3u dir
                QString rel = basepath + "/" + trackLocation;
                if (isFilepath(rel)) {
                    return rel;
                }
                // We couldn't match this to a real file so ignore it
            }
        }
        textline = stream->readLine();
    }

    // Signal we reached the end
    return 0;

}