2 * Copyright (C) 2003-2010 Neverball authors
4 * NEVERBALL is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
25 /*---------------------------------------------------------------------------*/
27 static void free_item(struct dir_item *item)
31 demo_free(item->data);
36 static void load_item(struct dir_item *item)
39 item->data = demo_load(item->path);
42 static int scan_item(struct dir_item *item)
44 return str_ends_with(item->path, ".nbr");
47 /*---------------------------------------------------------------------------*/
49 Array demo_dir_scan(void)
51 return fs_dir_scan("Replays", scan_item);
54 void demo_dir_load(Array items, int lo, int hi)
58 assert(lo >= 0 && lo < array_len(items));
59 assert(hi >= lo && hi < array_len(items));
61 for (i = lo; i <= hi; i++)
62 load_item(array_get(items, i));
65 void demo_dir_free(Array items)
69 for (i = 0; i < array_len(items); i++)
70 free_item(array_get(items, i));
75 /*---------------------------------------------------------------------------*/