-
Notifications
You must be signed in to change notification settings - Fork 0
/
xsfhelper.cpp
53 lines (44 loc) · 1.3 KB
/
xsfhelper.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
45
46
47
48
49
50
51
52
53
#include "xsfhelper.h"
#include <libxsf/file2sf.h>
#include <libxsf/filegsf.h>
#include <libxsf/fileusf.h>
#include <libxsf/filencsf.h>
#include <libxsf/filesnsf.h>
#include <libxsf/filemsu.h>
XSFHelper::XSFHelper(const QString &path)
: m_path(path)
{
}
XSFHelper::~XSFHelper()
{
deinit();
}
void XSFHelper::metaMode(bool meta)
{
m_meta = meta;
}
void XSFHelper::deinit()
{
delete m_input;
}
bool XSFHelper::initialize()
{
const QString &suffix = m_path.toLower();
if(suffix.endsWith(".2sf") || suffix.endsWith(".mini2sf")) m_input = new File2SFReader;
else if(suffix.endsWith(".gsf") || suffix.endsWith(".minigsf")) m_input = new FileGSFReader;
else if(suffix.endsWith(".usf") || suffix.endsWith(".miniusf")) m_input = new FileUSFReader;
else if(suffix.endsWith(".ncsf") || suffix.endsWith(".minincsf")) m_input = new FileNCSFReader;
else if(suffix.endsWith(".snsf") || suffix.endsWith(".minisnsf")) m_input = new FileSNSFReader;
else if(suffix.endsWith(".pcm") || suffix.endsWith(".msu")) m_input = new FileMSUReader;
if(!m_input)
{
qWarning("XSFHelper: load file suffix error");
return false;
}
if(!m_input->load(qPrintable(m_path), m_meta))
{
qWarning("XSFHelper: unable to open file");
return false;
}
return true;
}