core/collection: Directly save the queue in collection_save()
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
f413d14720
commit
79af4513b0
|
@ -21,24 +21,6 @@ public:
|
||||||
file_init(&f, "library.q", 0);
|
file_init(&f, "library.q", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void save()
|
|
||||||
{
|
|
||||||
GSList *cur = q_sort;
|
|
||||||
int field;
|
|
||||||
|
|
||||||
if (!file_open(&f, OPEN_WRITE))
|
|
||||||
return;
|
|
||||||
|
|
||||||
file_writef(&f, "%u %u", q_flags, g_slist_length(q_sort));
|
|
||||||
while (cur) {
|
|
||||||
field = GPOINTER_TO_INT(cur->data);
|
|
||||||
file_writef(&f, " %u %d", abs(field) - 1, field > 0);
|
|
||||||
cur = g_slist_next(cur);
|
|
||||||
}
|
|
||||||
file_writef(&f, "\n");
|
|
||||||
file_close(&f);
|
|
||||||
}
|
|
||||||
|
|
||||||
void load()
|
void load()
|
||||||
{
|
{
|
||||||
unsigned int field;
|
unsigned int field;
|
||||||
|
@ -60,6 +42,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
static LibraryQueue library_q;
|
static LibraryQueue library_q;
|
||||||
|
static struct file c_file;
|
||||||
|
|
||||||
struct scan_info {
|
struct scan_info {
|
||||||
struct library *library;
|
struct library *library;
|
||||||
|
@ -147,6 +130,7 @@ void collection_init(struct queue_ops *ops)
|
||||||
{
|
{
|
||||||
struct db_entry *track, *next;
|
struct db_entry *track, *next;
|
||||||
|
|
||||||
|
file_init(&c_file, "library.q", 0);
|
||||||
queue_init(&library_q, Q_ENABLED | Q_REPEAT | Q_ADD_FRONT, ops);
|
queue_init(&library_q, Q_ENABLED | Q_REPEAT | Q_ADD_FRONT, ops);
|
||||||
|
|
||||||
db_for_each(track, next, track_db_get()) {
|
db_for_each(track, next, track_db_get()) {
|
||||||
|
@ -173,8 +157,22 @@ void collection_deinit()
|
||||||
|
|
||||||
void collection_save(struct queue *queue, enum queue_flags flag)
|
void collection_save(struct queue *queue, enum queue_flags flag)
|
||||||
{
|
{
|
||||||
if (&library_q == queue)
|
GSList *cur = library_q.q_sort;
|
||||||
library_q.save();
|
int field;
|
||||||
|
|
||||||
|
if (&library_q != queue)
|
||||||
|
return;
|
||||||
|
if (!file_open(&c_file, OPEN_WRITE))
|
||||||
|
return;
|
||||||
|
|
||||||
|
file_writef(&c_file, "%u %u", library_q.q_flags, g_slist_length(cur));
|
||||||
|
while (cur) {
|
||||||
|
field = GPOINTER_TO_INT(cur->data);
|
||||||
|
file_writef(&c_file, " %u %d", abs(field) - 1, field > 0);
|
||||||
|
cur = g_slist_next(cur);
|
||||||
|
}
|
||||||
|
file_writef(&c_file, "\n");
|
||||||
|
file_close(&c_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct library *collection_add(const gchar *path)
|
struct library *collection_add(const gchar *path)
|
||||||
|
|
Loading…
Reference in New Issue