19 #include <QTextStream> 20 #include <QStringList> 31 m_error = QFile::tr(
"File or URL \"%1\" could not be retrieved")
43 m_error = QFile::tr(
"File or URL \"%1\" could not be retrieved")
65 m_file =
new QFile(filename);
69 m_error = QFile::tr(
"File \"%1\" does not exist")
71 }
else if (!
m_file->open(QIODevice::ReadOnly | QIODevice::Text)) {
72 m_error = QFile::tr(
"Failed to open file \"%1\"")
80 m_basedir = QFileInfo(filename).dir().canonicalPath();
112 while (!in.atEnd()) {
117 QString chunk = in.readLine();
118 QStringList lines = chunk.split(
'\r', QString::SkipEmptyParts);
120 for (
int li = 0; li < lines.size(); ++li) {
122 QString line = lines[li];
124 if (line.startsWith(
"#"))
continue;
132 if (QFileInfo(line).isRelative() &&
m_basedir !=
"") {
133 QString testpath = QDir(
m_basedir).filePath(line);
134 if (QFileInfo(testpath).exists() &&
135 QFileInfo(testpath).isFile()) {
136 cerr <<
"Path \"" << line
137 <<
"\" is relative, resolving to \"" 145 playlist.push_back(line);
155 extensions.insert(
"m3u");
virtual ~PlaylistFileReader()
virtual bool isOK() const
QString getLocation() const
Return the location filename or URL as passed to the constructor.
std::vector< QString > Playlist
static void getSupportedExtensions(std::set< QString > &extensions)
PlaylistFileReader(QString path)
void waitForData()
Block on a sub-event-loop until the whole of the data has been retrieved (if it is remote).
virtual Playlist load() const
FileSource is a class used to refer to the contents of a file that may be either local or at a remote...
bool isRemote() const
Return true if this FileSource is referring to a remote URL.
QString getLocalFilename() const
Return the name of the local file this FileSource refers to.
virtual QString getError() const
bool isAvailable()
Return true if the file or remote URL exists.