blob: 0eae4a1be8d6e14bb38c3894865be59c0ab53665 (
plain)
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
|
#include "cleanconfig.h"
#include <QFile>
#include <QDir>
#define DO_REMOVE
//#define REMOVE_FILE_SETTINGS
void CleanConfig::clean(const QString & config_path) {
qDebug("CleanConfig::clean");
QStringList files;
files << "smplayer.ini" << "styles.ass" << "smplayer_files.ini"
<< "ytcode.script" << "yt.js" << "sig.ini" << "player_info.ini"
<< "device_info.ini" << "hdpi.ini" << "playlist.ini";
QStringList files_to_delete;
foreach(QString f, files) {
QString s = config_path +"/"+ f;
if (QFile::exists(s)) files_to_delete << s;
}
#ifdef REMOVE_FILE_SETTINGS
QString s = config_path + "/file_settings";
if (QFile::exists(s)) files_to_delete << listDir(s);
#endif
printf("Deleting files:\n");
for (int n = 0; n < files_to_delete.count(); n++) {
printf("Delete: %s\n", files_to_delete[n].toUtf8().constData());
#ifdef DO_REMOVE
QFile::remove(files_to_delete[n]);
#endif
}
}
QStringList CleanConfig::listDir(const QString &path) {
QDir dir(path);
QStringList file_list;
foreach(QString file, dir.entryList(QDir::Files)) {
file_list << QFileInfo(dir, file).absoluteFilePath();
}
foreach(QString sub_dir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
file_list << listDir(path +"/"+ sub_dir);
}
return file_list;
}
|