-
Notifications
You must be signed in to change notification settings - Fork 1
/
archivereader.cpp
44 lines (38 loc) · 1.03 KB
/
archivereader.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "archivereader.h"
#include <QProcess>
#include <qmmp/qmmp.h>
#define ARCHIVE_PATH (Qmmp::pluginPath() + "/../archive.tkx")
QStringList ArchiveReader::filters()
{
QStringList path;
path << "*.mdr" << "*.s3r" << "*.xmr" << "*.itr";
path << "*.mdz" << "*.s3z" << "*.xmz" << "*.itz";
path << "*.mdgz" << "*.s3gz" << "*.xmgz" << "*.itgz";
path << "*.mdbz" << "*.s3bz" << "*.xmbz" << "*.itbz";
return path;
}
bool ArchiveReader::isSupported(const QString &path)
{
const QString &filePath = path.toLower();
for(const QString &suffix : filters())
{
if(filePath.endsWith(suffix.mid(1)))
{
return true;
}
}
return false;
}
QByteArray ArchiveReader::unpack(const QString &path)
{
if(!QFile::exists(ARCHIVE_PATH) || path.isEmpty())
{
return QByteArray();
}
QProcess process;
QStringList args;
args << "-so" << "e" << path;
process.start(ARCHIVE_PATH, args);
process.waitForFinished();
return process.readAllStandardOutput();
}