]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/kpath.cc
* lily/dots.cc (print): replace -
[lilypond.git] / lily / kpath.cc
index 1f3b00573738f8c2c0e13f93fbd4319af5bc3a12..592d70d09a3a20d2295c12631dc1a13122ee767e 100644 (file)
@@ -44,22 +44,16 @@ extern "C" {
 #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 "";
 }
@@ -80,11 +74,9 @@ kpathsea_find_tfm (char const *name)
             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;
@@ -149,6 +141,22 @@ kpathsea_gulp_file_to_string (String 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},"