]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/kpath.cc
* SConstruct: Further development.
[lilypond.git] / lily / kpath.cc
index cea15b6cd9069985e2b6299859f8ddbda5c4f007..2db7be8ee137901798a368380845424c4625130b 100644 (file)
@@ -21,7 +21,7 @@ I found a somewhat more elegant patch for this: Just #include
 
 */
 #include <unistd.h>    
-#include "config.h"
+#include "config.hh"
 
 #define popen REALLYUGLYKLUDGE
 #define pclose ANOTHERREALLYUGLYKLUDGE
@@ -45,7 +45,7 @@ String
 kpathsea_find_afm (char const * name)
 {
 #if (KPATHSEA && HAVE_KPSE_FIND_FILE)
-  char * name_ptr =  kpse_find_file (name, kpse_afm_format, true);
+  char * name_ptr =  kpse_find_file (name, kpse_afm_format, false);
 
   if (!name_ptr)
     {
@@ -75,7 +75,7 @@ kpathsea_find_tfm (char const *name)
           if (p)
             p = kpse_find_file (name, kpse_mf_format, true);
 
-        but we assume that if there is a .PFA, there is also a .TFM,
+            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);
@@ -147,16 +147,30 @@ kpathsea_gulp_file_to_string (String name)
   return string;
 }
 
-LY_DEFINE (ly_kpathsea_gulp_file, "ly:kpathsea-gulp-file",
+
+
+LY_DEFINE (ly_kpathsea_expand_path, "ly:kpathsea-expand-path",
           1, 0, 0, (SCM name),
-          "Read the file @var{name}, and return its contents in a string.  "
-          "The file is looked up using the search path and kpathsea.")
+          "Read the file @var{name}, and return its expanded path, or "
+          "@code{#f} if not found.")
 {
-  SCM_ASSERT_TYPE (ly_string_p (name), name, SCM_ARG1, __FUNCTION__, "string");
-  return scm_makfrom0str
-    (kpathsea_gulp_file_to_string (ly_scm2string (name)).to_str0 ());
+  SCM_ASSERT_TYPE (ly_c_string_p (name), name, SCM_ARG1, __FUNCTION__, "string");
+
+  String nm = ly_scm2string (name);
+  String filename = global_path.find (nm);
+  if (filename.is_empty ())
+    {
+      char *p = kpse_find_file (nm.to_str0 (), kpathsea_find_format (nm),
+       true);
+      if (p)
+       return scm_makfrom0str (p);
+      else
+       return SCM_BOOL_F;
+    }
+  return scm_makfrom0str (filename.to_str0 ());
 }
 
+
 void
 initialize_kpathsea (char *av0)
 {