summaryrefslogtreecommitdiff
path: root/src/mfs_subr.c
diff options
context:
space:
mode:
authorKjetil Ørbekk <orbekk@pvv.ntnu.no>2008-08-15 20:48:05 +0200
committerKjetil Ørbekk <orbekk@pvv.ntnu.no>2008-08-15 20:48:05 +0200
commit73786a63d67d7f63620c55b20a9937fed2f9718c (patch)
tree0a2e6d05a136714cad3b4dbc8561d9dab7fe2845 /src/mfs_subr.c
parent85ec65543f15a9b722e122dd7ef30e147585950f (diff)
- Added lookup functions for scanning paths
Diffstat (limited to 'src/mfs_subr.c')
-rw-r--r--src/mfs_subr.c25
1 files changed, 22 insertions, 3 deletions
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];
@@ -850,6 +857,18 @@ mfs_lookup_stat(void *data, const char *str)
}
/*
+ * 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.
*
* Examples: