void metadb_handle_list_helper::sort_by_relative_path_get_order(metadb_handle_list_cref p_list,t_size* order) { const t_size count = p_list.get_count(); t_size n; pfc::array_t<custom_sort_data> data; data.set_size(count); static_api_ptr_t<library_manager> api; pfc::string8_fastalloc temp; temp.prealloc(512); for(n=0;n<count;n++) { metadb_handle_ptr item; p_list.get_item_ex(item,n); if (!api->get_relative_path(item,temp)) temp = ""; data[n].index = n; data[n].text = makeSortString(temp); //data[n].subsong = item->get_subsong_index(); } pfc::sort_t(data,custom_sort_compare<1>,count); //qsort(data.get_ptr(),count,sizeof(custom_sort_data),(int (__cdecl *)(const void *elem1, const void *elem2 ))custom_sort_compare); for(n=0;n<count;n++) { order[n]=data[n].index; delete[] data[n].text; } }
t_filesize metadb_handle_list_helper::calc_total_size(metadb_handle_list_cref p_list, bool skipUnknown) { pfc::avltree_t< const char*, metadb::path_comparator > beenHere; // metadb_handle_list list(p_list); // list.sort_t(metadb::path_compare_metadb_handle); t_filesize ret = 0; t_size n, m = p_list.get_count(); for(n=0;n<m;n++) { bool isNew; metadb_handle_ptr h; p_list.get_item_ex(h, n); beenHere.add_ex( h->get_path(), isNew); if (isNew) { t_filesize t = h->get_filesize(); if (t == filesize_invalid) { if (!skipUnknown) return filesize_invalid; } else { ret += t; } } } return ret; }