diff --git a/core/library.cpp b/core/library.cpp index 153641aa..1ae19d2a 100644 --- a/core/library.cpp +++ b/core/library.cpp @@ -10,39 +10,8 @@ extern "C" { #include -class LibraryQueue : public queue { -private: - file f; - -public: - - LibraryQueue() - { - file_init(&f, "library.q", 0); - } - - void load() - { - unsigned int field; - int ascending; - unsigned int n; - - if (!file_open(&f, OPEN_READ)) - return; - - file_readf(&f, "%u %u", &q_flags, &n); - for (unsigned int i = 0; i < n; i++) { - file_readf(&f, "%u %d", &field, &ascending); - queue_sort(this, (compare_t)(field + 1), (i == 0) ? true : false); - if (ascending == false) - queue_sort(this, (compare_t)(field + 1), false); - } - file_close(&f); - } -}; - -static LibraryQueue library_q; -static struct file c_file; +static struct queue library_q; +static struct file c_file; struct scan_info { struct library *library; @@ -125,10 +94,11 @@ static void validate_library(void *data) /* * External API begins here */ - void collection_init(struct queue_ops *ops) { struct db_entry *track, *next; + unsigned int i, n = 0; + int field, ascending; file_init(&c_file, "library.q", 0); queue_init(&library_q, Q_ENABLED | Q_REPEAT | Q_ADD_FRONT, ops); @@ -139,7 +109,18 @@ void collection_init(struct queue_ops *ops) } queue_unset_flag(&library_q, Q_ADD_FRONT); - library_q.load(); + if (file_open(&c_file, OPEN_READ)) + file_readf(&c_file, "%u %u", &library_q.q_flags, &n); + + for (i = 0; i < n; i++) { + file_readf(&c_file, "%u %d", &field, &ascending); + queue_sort(&library_q, (compare_t)(field + 1), + (i == 0) ? true : false); + if (ascending == false) + queue_sort(&library_q, (compare_t)(field + 1), false); + } + file_close(&c_file); + if (!library_q.q_sort) { queue_sort(&library_q, COMPARE_ARTIST, true); queue_sort(&library_q, COMPARE_YEAR, false);