From 73786a63d67d7f63620c55b20a9937fed2f9718c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjetil=20=C3=98rbekk?= Date: Fri, 15 Aug 2008 20:48:05 +0200 Subject: - Added lookup functions for scanning paths --- src/mfs_subr.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mfs_subr.c b/src/mfs_subr.c index b4dfde4..21cc5d6 100644 --- a/src/mfs_subr.c +++ b/src/mfs_subr.c @@ -130,6 +130,7 @@ mfs_reload_config() FILE *f = fopen(mfsrc, "r"); char line[4096]; sqlite3 *handle; + struct lookuphandle *lh; res = sqlite3_open(DBNAME, &handle); if (res) { @@ -151,8 +152,14 @@ mfs_reload_config() } } - sqlite3_close(handle); free (mfsrc); + + /* Do the actual loading */ + lh = mfs_lookup_start(0, handle, mfs_lookup_load_path, + "SELECT path FROM path"); + mfs_lookup_finish(lh); + + sqlite3_close(handle); return (0); } @@ -177,7 +184,6 @@ mfs_initscan(char *musicpath) if (error != 0) return (error); - traverse_hierarchy(musicpath, mfs_scan); sqlite3_close(handle); return (0); } @@ -188,8 +194,9 @@ mfs_initscan(char *musicpath) * sub-directories. */ void -traverse_hierarchy(char *dirpath, traverse_fn_t fileop) +traverse_hierarchy(const char *dirpath, traverse_fn_t fileop) { + DEBUG("traversing %s\n", dirpath); DIR *dirp; struct dirent *dp; char filepath[MAXPATHLEN]; @@ -849,6 +856,18 @@ mfs_lookup_stat(void *data, const char *str) return (1); } +/* + * Load a path into database + */ +int +mfs_lookup_load_path(void *data, const char *str) +{ + handle = (sqlite3 *)data; + traverse_hierarchy(str, mfs_scan); + + return (1); +} + /* * Guess on a filetype for a path. * -- cgit v1.2.3