- DIR *dir;
- struct dirent *e;
- FcChar8 *subdir;
- FcBool added = FcFalse;
-
- if (!(dir = opendir ((char *) d)))
- return FcFalse;
- if (!(subdir = (FcChar8 *) malloc (strlen ((char *) d) + FC_MAX_FILE_LEN + 2)))
- {
- fprintf (stderr, "out of memory");
- return FcFalse;
- }
- while ((e = readdir (dir)))
- {
- if (strcmp (e->d_name, ".") && strcmp (e->d_name, "..") &&
- strlen (e->d_name) < FC_MAX_FILE_LEN)
- {
- strcpy ((char *)subdir, (char *)d);
- strcat ((char *)subdir, "/");
- strcat ((char *)subdir, e->d_name);
- if (FcFileIsDir (subdir))
- {
- if (FcConfigInodeMatchFontDir(config, subdir))
- continue; /* already added */
- FcStrSetAddFilename (config->fontDirs, subdir);
- FcConfigAddFontDirSubdirs (config, subdir);
- added = FcTrue;
- }
- }
- }
- free (subdir);
- closedir (dir);
- return added;
+ return (FcConfigAddConfigDir (config, d) &&
+ FcConfigAddFontDir (config, d));