1#ifndef SCAN_H
2#define SCAN_H
3
4#include <stddef.h>
5#include <stdint.h>
6
7struct item {
8 uint64_t id;
9 char* path;
10};
11
12struct library {
13 struct item* items;
14 size_t len;
15 size_t cap;
16};
17
18/**
19 * @brief Free all memory owned by a library
20 *
21 * @note Safe to call multiple times
22 *
23 * @param l Library to free
24 */
25void scan_library_free(struct library* l);
26
27/**
28 * @brief Build library by recursively scanning given directory
29 *
30 * @param l Output library (initialised by function)
31 * @param root Media root directory
32 *
33 * @return 0=Success, -1=Failure
34 */
35int scan_library(struct library* l, const char* root);
36
37/**
38 * @brief Rescan given directory and replace current library contents
39 *
40 * @note On success, old library contents are freed.
41 *
42 * @param l Library to replace
43 * @param root Media root directory
44 *
45 * @return 0=Success, -1=Failure
46 */
47int scan_library_rescan(struct library* l, const char* root);
48
49#endif /* SCAN_H */
50