3
MyType::MyType(QObject *parent) :
14
bool MyType::write(QString source, const QString &data)
19
if(source.startsWith("file://"))
20
source.remove("file://");
22
//maybe useful in the future but i doesn't work anyway xD
23
// QDir dir = QFileInfo(source).absoluteDir();
28
if (!file.open(QFile::ReadWrite))
31
QTextStream out(&file);
37
QString MyType::read(QString source)
42
if(source.startsWith("file://"))
43
source.remove("file://");
46
if (!file.open(QFile::ReadOnly | QFile::Truncate))
49
QString data = file.readAll();
53
bool MyType::rename(QString source, const QString &fileName)
58
if(source.startsWith("file://"))
59
source.remove("file://");
62
return file.rename(fileName);
65
bool MyType::remove(QString source)
70
if(source.startsWith("file://"))
71
source.remove("file://");
77
QString MyType::getFileName(QString source)
82
if(source.startsWith("file://"))
83
source.remove("file://");
86
QString name = fi.completeBaseName();
87
QRegularExpression rx("\((\\d+)\)");
88
QRegularExpressionMatch match = rx.match(name);
90
name.remove(match.capturedStart(0)-1,match.capturedLength(0)+2);
95
QString MyType::getSuffix(QString source)
100
if(source.startsWith("file://"))
101
source.remove("file://");
103
QFileInfo fi(source);
107
QString MyType::getFullName(QString source)
109
if (source.isEmpty())
112
if(source.startsWith("file://"))
113
source.remove("file://");
115
QFileInfo fi(source);
116
return fi.fileName();
119
bool MyType::exists(QString source)
121
if (source.isEmpty())
124
if(source.startsWith("file://"))
125
source.remove("file://");
127
QFileInfo fi(source);
131
bool MyType::isWritable(QString source)
133
if (source.isEmpty())
136
if(source.startsWith("file://"))
137
source.remove("file://");
139
QFileInfo fi(source);
140
return fi.isWritable();
143
QStringList MyType::getLocalFileList(QString path)
150
if(path.startsWith("file://"))
151
path.remove("file://");
154
list = dir.entryList(QDir::Files);