Index: trunk/src/plug_footprint.c =================================================================== --- trunk/src/plug_footprint.c (revision 7935) +++ trunk/src/plug_footprint.c (revision 7936) @@ -184,6 +184,7 @@ l->name = pcb_strdup(name); l->parent = parent; l->type = LIB_DIR; + l->data.dir.backend = NULL; vtlib_init(&l->data.dir.children); return l; } @@ -399,8 +400,25 @@ int pcb_fp_rehash(pcb_fplibrary_t *l) { + pcb_plug_fp_t *be; + char *path; + int res; + if (l == NULL) { pcb_fp_free_children(&pcb_library); return pcb_fp_read_lib_all(); } + if (l->type != PCB_FP_DIR) + return -1; + + be = l->data.dir.backend; + if ((be == NULL) || (be->load_dir == NULL)) + return -1; + + path = pcb_strdup(l->name); + pcb_fp_rmdir(l); + res = be->load_dir(be, path, 1); + pcb_fp_sort_children(&pcb_library); + free(path); + return res; } Index: trunk/src/plug_footprint_act.c =================================================================== --- trunk/src/plug_footprint_act.c (revision 7935) +++ trunk/src/plug_footprint_act.c (revision 7936) @@ -31,7 +31,33 @@ static const char pcb_acth_fp_rehash[] = "Flush the library index; rescan all library search paths and rebuild the library index. Useful if there are changes in the library during a pcb-rnd session."; static int pcb_act_fp_rehash(int argc, const char **argv, pcb_coord_t x, pcb_coord_t y) { - pcb_fp_rehash(NULL); + pcb_fplibrary_t *l; + + if (argc == 0) { + pcb_fp_rehash(NULL); + return 0; + } + + l = pcb_fp_lib_search(&pcb_library, argv[0]); + if (l == NULL) { + pcb_message(PCB_MSG_ERROR, "Can't find library path %s\n", argv[0]); + return 1; + } + + if (l->type != PCB_FP_DIR) { + pcb_message(PCB_MSG_ERROR, "Library path %s is not a directory\n", argv[0]); + return 1; + } + + if (l->data.dir.backend == NULL) { + pcb_message(PCB_MSG_ERROR, "Library path %s is not a top level directory of a fp_ plugin\n", argv[0]); + return 1; + } + + if (pcb_fp_rehash(l) != 0) { + pcb_message(PCB_MSG_ERROR, "Failed to rehash %s\n", argv[0]); + return 1; + } return 0; } Index: trunk/src/vtlibrary.h =================================================================== --- trunk/src/vtlibrary.h (revision 7935) +++ trunk/src/vtlibrary.h (revision 7936) @@ -61,6 +61,7 @@ union { struct { /* type == LIB_DIR */ vtlib_t children; + void *backend; /* pcb_plug_fp_t* */ } dir; struct { /* type == LIB_FOOTPRINT */ char *loc_info; Index: trunk/src_plugins/fp_fs/fp_fs.c =================================================================== --- trunk/src_plugins/fp_fs/fp_fs.c (revision 7935) +++ trunk/src_plugins/fp_fs/fp_fs.c (revision 7936) @@ -260,7 +260,14 @@ static int fp_fs_load_dir(pcb_plug_fp_t *ctx, const char *path, int force) { - return fp_fs_load_dir_(&pcb_library, ".", path, 1); + int res; + res = fp_fs_load_dir_(&pcb_library, ".", path, 1); + if (res >= 0) { + pcb_fplibrary_t *l = pcb_fp_lib_search(&pcb_library, "fs"); + if ((l != NULL) && (l->type == PCB_FP_DIR)) + l->data.dir.backend = ctx; + } + return res; } typedef struct { Index: trunk/src_plugins/fp_wget/gedasymbols.c =================================================================== --- trunk/src_plugins/fp_wget/gedasymbols.c (revision 7935) +++ trunk/src_plugins/fp_wget/gedasymbols.c (revision 7936) @@ -78,6 +78,7 @@ gds_t vpath; int vpath_base_len; fp_get_mode wmode = FP_WGET_OFFLINE; + pcb_fplibrary_t *l; if (strncmp(path, REQUIRE_PATH_PREFIX, strlen(REQUIRE_PATH_PREFIX)) != 0) return -1; @@ -115,12 +116,16 @@ gds_init(&vpath); gds_append_str(&vpath, REQUIRE_PATH_PREFIX); + + l = pcb_fp_mkdir_p(vpath.array); + l->data.dir.backend = ctx; + gds_append(&vpath, '/'); vpath_base_len = vpath.used; + while(fgets(line, sizeof(line), f) != NULL) { char *end, *fn; - pcb_fplibrary_t *l; if (*line == '#') continue;