#include "warn.hh"
String
-kpathsea_find_afm (char const * name)
+kpathsea_find_afm (char const *name)
{
#if (KPATHSEA && HAVE_KPSE_FIND_FILE)
- char * name_ptr = kpse_find_file (name, kpse_afm_format, false);
- if (!name_ptr)
- {
- /*
- don't mutter about afms, since we try to find them first, and lots of
- TFMs don't have AFMs.
- */
- // warning (_f ("kpathsea couldn't find AFM file `%s'", name));
- }
- else
- return name_ptr;
-
+ if (char *afm = kpse_find_file (name, kpse_afm_format, false))
+ return afm;
+#if 0 /* Do not mutter about afms, since we try to find them first, and
+ lots of TFMs don't have AFMs. */
+ warning (_f ("kpathsea can not find AFM file `%s'", name));
+#endif
#endif
return "";
}
but we assume that if there is a .PFA, there is also a .TFM,
and it's no use generating TFMs on the fly, because PFAs cannot
be generated on the fly. */
- char *p = kpse_find_file (name, kpse_tfm_format, false);
- if (!p)
- warning (_f ("kpathsea can not find TFM file: `%s'", name));
- else
- file_name = p;
+ if (char *tfm = kpse_find_file (name, kpse_tfm_format, false))
+ return tfm;
+ warning (_f ("kpathsea can not find TFM file: `%s'", name));
}
#endif
return file_name;
return string;
}
+
+LY_DEFINE (ly_find_file, "ly:find-file",
+ 1, 0, 0, (SCM name),
+ "Return the absolute file name of @var{name},"
+ "or @code{#f} if not found.")
+{
+ SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG1, __FUNCTION__, "string");
+
+ String nm = ly_scm2string (name);
+ String file_name = global_path.find (nm);
+ if (file_name.is_empty ())
+ return SCM_BOOL_F;
+
+ return scm_makfrom0str (file_name.to_str0 ());
+}
+
LY_DEFINE (ly_kpathsea_find_file, "ly:kpathsea-find-file",
1, 0, 0, (SCM name),
"Return the absolute file name of @var{name},"