-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cc
62 lines (47 loc) · 1.22 KB
/
main.cc
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
54
55
56
57
58
59
60
61
#include <libaudcore/i18n.h>
#include <libaudcore/playlist.h>
#include <libaudcore/plugin.h>
#include <QUrl>
#include <QDateTime>
#include <QFileInfo>
#define EXPORT __attribute__((visibility("default")))
#define APPLICATION_ID "484736379171897345"
class SortPlugin : public GeneralPlugin {
public:
static const char about[];
static constexpr PluginInfo info = {
N_("Sort"),
"audacious-plugin-sort",
about
};
constexpr SortPlugin() : GeneralPlugin (info, false) {}
bool init();
void cleanup();
};
EXPORT SortPlugin aud_plugin_instance;
const char SortPlugin::about[] = N_("Simple Sort Plugin");
time_t get_modified_time(const char* filepath)
{
QUrl url(filepath);
QString path = url.toLocalFile();
QFileInfo file_info(path);
return file_info.lastModified().toSecsSinceEpoch();
}
static int compare_by_modified_date(const char * a, const char * b)
{
if(get_modified_time(a) < get_modified_time(b))
{
return -1;
}
else
{
return 1;
}
}
bool SortPlugin::init() {
Playlist::active_playlist().sort_by_filename(compare_by_modified_date);
Playlist::active_playlist().activate();
return true;
}
void SortPlugin::cleanup() {
}