GDir *dir = NULL;
GError *error = NULL;
const char *name;
- GPtrArray *dir_array = NULL;
+ GQueue *dir_queue = NULL;
char *current_path = NULL;
char *path = NULL;
int (*scan_function)(sqlite3 *, const char*, const char*, uid_t) = NULL;
- dir_array = g_ptr_array_new();
- g_ptr_array_add(dir_array, start_path);
+ dir_queue = g_queue_new();
+ g_queue_push_tail(dir_queue, start_path);
scan_function = (check_exists == false) ? ms_insert_item_batch : ms_validate_item;
- while (dir_array->len != 0) {
- current_path = g_ptr_array_index(dir_array, 0);
- g_ptr_array_remove_index(dir_array, 0);
-
+ while ((current_path = g_queue_pop_head(dir_queue))) {
if (__msc_is_power_off()) {
ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
MS_SAFE_FREE(current_path);
MS_SAFE_FREE(path);
} else {
if (is_recursive) {
- g_ptr_array_add(dir_array, path);
+ g_queue_push_tail(dir_queue, path);
} else {
ret = ms_insert_folder(handle, storage_id, path, uid);
if (ret != MS_MEDIA_ERR_NONE)
g_dir_close(dir);
}
- g_ptr_array_free(dir_array, TRUE);
+ g_queue_free_full(dir_queue, g_free);
return ret;
}