Index: trunk/src/file.c =================================================================== --- trunk/src/file.c (revision 309) +++ trunk/src/file.c (revision 310) @@ -128,7 +128,7 @@ static int WritePCBFile (char *); static int WritePipe (char *, bool); static int ParseLibraryTree (void); -static int LoadNewlibFootprintsFromDir(const char *subdir, const char *toppath); +static int LoadNewlibFootprintsFromDir(const char *subdir, const char *toppath, int is_root); static const char *pcb_basename (const char *p); /* --------------------------------------------------------------------------- @@ -1224,7 +1224,7 @@ return 0; } -static int LoadNewlibFootprintsFromDir(const char *subdir, const char *toppath) +static int LoadNewlibFootprintsFromDir(const char *subdir, const char *toppath, int is_root) { LibraryMenuTypePtr menu = NULL; /* Pointer to PCB's library menu structure */ list_st_t l; @@ -1246,12 +1246,12 @@ l.subdirs = NULL; l.children = 0; - pcb_fp_list(working, 0, list_cb, &l); + pcb_fp_list(working, 0, list_cb, &l, is_root); /* now recurse to each subdirectory mapped in the previous call; by now we don't care if menu is ruined by the realloc() in GetLibraryMenuMemory() */ for(d = l.subdirs; d != NULL; d = nextd) { - l.children+=LoadNewlibFootprintsFromDir(d->subdir, d->parent); + l.children+=LoadNewlibFootprintsFromDir(d->subdir, d->parent, 0); nextd = d->next; free(d->subdir); free(d->parent); @@ -1301,7 +1301,7 @@ #endif /* Next read in any footprints in the top level dir */ - n_footprints += LoadNewlibFootprintsFromDir(".", toppath); + n_footprints += LoadNewlibFootprintsFromDir(".", toppath, 1); } #ifdef DEBUG Index: trunk/src/libpcb_fp.c =================================================================== --- trunk/src/libpcb_fp.c (revision 309) +++ trunk/src/libpcb_fp.c (revision 310) @@ -159,7 +159,7 @@ return PCB_FP_INVALID; } -int pcb_fp_list(const char *subdir, int recurse, int (*cb) (void *cookie, const char *subdir, const char *name, pcb_fp_type_t type), void *cookie) +int pcb_fp_list(const char *subdir, int recurse, int (*cb) (void *cookie, const char *subdir, const char *name, pcb_fp_type_t type), void *cookie, int subdir_may_not_exist) { char olddir[MAXPATHLEN + 1]; /* The directory we start out in (cwd) */ char fn[MAXPATHLEN + 1], *fn_end; @@ -179,7 +179,8 @@ } if (chdir(subdir)) { - ChdirErrorMessage(subdir); + if (!subdir_may_not_exist) + ChdirErrorMessage(subdir); return 0; } @@ -247,7 +248,7 @@ if ((S_ISDIR(buffer.st_mode)) || (S_ISLNK(buffer.st_mode))) { cb(cookie, subdir, subdirentry->d_name, PCB_FP_DIR); if (recurse) { - n_footprints += pcb_fp_list(fn, recurse, cb, cookie); + n_footprints += pcb_fp_list(fn, recurse, cb, cookie, 0); } continue; } @@ -320,7 +321,7 @@ memcpy(path, p, end-p); path[end-p] = '\0'; /* printf(" in '%s'\n", path);*/ - pcb_fp_list(path, 1, pcb_fp_search_cb, &ctx); + pcb_fp_list(path, 1, pcb_fp_search_cb, &ctx, 1); if (ctx.path != NULL) { sprintf(path, "%s%c%s", ctx.path, PCB_DIR_SEPARATOR_C, basename); free(ctx.path); Index: trunk/src/libpcb_fp.h =================================================================== --- trunk/src/libpcb_fp.h (revision 309) +++ trunk/src/libpcb_fp.h (revision 310) @@ -8,8 +8,9 @@ } pcb_fp_type_t; /* List all symbols, optionally recursively, from CWD/subdir. For each symbol - or subdir, call the callback. Ignore file names starting with .*/ -int pcb_fp_list(const char *subdir, int recurse, int (*cb)(void *cookie, const char *subdir, const char *name, pcb_fp_type_t type), void *cookie); + or subdir, call the callback. Ignore file names starting with + If subdir_may_not_exist is non-zero, don't complain if the top subdir does not exist .*/ +int pcb_fp_list(const char *subdir, int recurse, int (*cb)(void *cookie, const char *subdir, const char *name, pcb_fp_type_t type), void *cookie, int subdir_may_not_exist); /* Decide about the type of a footprint file by reading the content*/ pcb_fp_type_t pcb_fp_file_type(const char *fn);