]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/kpath.cc
patch::: 1.3.135.jcn2
[lilypond.git] / lily / kpath.cc
index fe928b693513e5d0244f96b5b235618fd6363915..8fa0c142bd8fc257fd6b9765737a06a0c6d95d39 100644 (file)
@@ -20,6 +20,12 @@ extern "C" {
 }
 #endif
 
+#include <sys/types.h>
+#include <fcntl.h>
+#if HAVE_SYS_STAT_H 
+#include <sys/stat.h>
+#endif
+
 #include "kpath.hh"
 
 
@@ -52,16 +58,27 @@ ly_init_kpath (char *av0)
   kpse_maketex_option("tfm", TRUE);
 
   /*
-    UGH: should not use DIR_DATADIR, but /var,  
-   */
+    UGH: should not use DIR_DATADIR, but /var,
 
-  /*
-    ugh: apparently the program_args is non-functional.
+    hmm, but where to get /var?
+    
    */
-  kpse_format_info[kpse_tfm_format].program ="mktextfm --destdir " DIR_DATADIR "/tfm";
 
-  kpse_format_info[kpse_tfm_format].client_path =
-    (DIR_DATADIR "/tfm" );
+  int fd;
+  struct stat stat_buf;
+  if (stat (DIR_DATADIR "/tfm", &stat_buf) == 0
+      && (S_ISDIR (stat_buf.st_mode) || S_ISLNK (stat_buf.st_mode))
+      // ugh, howto test if we can write there?
+      //      && (stat_buf.st_mode & S_IWUSR))
+      && ((fd = open (DIR_DATADIR "/tfm/lily", O_CREAT)) != -1))
+    {
+      close (fd);
+      unlink (DIR_DATADIR "/tfm/lily");
+      kpse_format_info[kpse_tfm_format].program ="mktextfm --destdir " DIR_DATADIR "/tfm";
+
+      kpse_format_info[kpse_tfm_format].client_path =
+       (DIR_DATADIR "/tfm" );
+    }
   
 #endif
 }