]> git.donarmstrong.com Git - lilypond.git/commitdiff
* flower/file-path.cc (find): don't throw away file_name.dir, but
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 19 May 2005 22:57:50 +0000 (22:57 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 19 May 2005 22:57:50 +0000 (22:57 +0000)
append to it. Fixes \include with directories.

* flower/include/file-path.hh (class File_path): don't derive from
Array<String>.

* flower/include/file-name.hh (class File_name): remove to_str0()

* lily/hara-kiri-engraver.cc (acknowledge_grob): split
Hara_kiri_engraver in separate file.

ChangeLog
flower/file-name.cc
flower/file-path.cc
flower/include/file-name.hh
flower/include/file-path.hh
lily/hara-kiri-engraver.cc

index b50334e23a3859514f02bc2fc61527a412d198ea..1576d999d1c22b89d48aac5166dba513679071df 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2005-05-20  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * flower/file-path.cc (find): don't throw away file_name.dir, but
+       append to it. Fixes \include with directories.
+
+       * flower/include/file-path.hh (class File_path): don't derive from
+       Array<String>.
+
+       * flower/include/file-name.hh (class File_name): remove to_str0()
+
        * lily/hara-kiri-engraver.cc (acknowledge_grob): split
        Hara_kiri_engraver in separate file.
 
index 8d1a3fae8c3acbe2f8d2be9e95f411eef022e981..1763a546c054ca12c0715cdcf60fd3e3dbf31fde 100644 (file)
@@ -75,11 +75,6 @@ File_name::to_string () const
   return s;
 }
 
-char const *
-File_name::to_str0 () const
-{
-  return to_string ().to_str0 ();
-}
 
 File_name::File_name (String file_name)
 {
index 32f174943ac9ce6aee17b54b740fb557ee455eb7..783b1095eac6c66af45419e5c56abad28e90fd9e 100644 (file)
@@ -31,7 +31,7 @@
 Array<String>
 File_path::directories () const
 {
-  return *this;
+  return dirs_;
 }
 
 void
@@ -41,7 +41,7 @@ File_path::parse_path (String p)
   while ((len = p.length ()) )
     {
       int i = p.index (PATHSEP);
-      if (i <0) 
+      if (i < 0) 
        i = len;
       append (p.left_string (i));
       p = p.right_string (len - i - 1);
@@ -59,6 +59,7 @@ is_file (String file_name)
   if (!(sbuf.st_mode & __S_IFREG))
     return false;
 #endif
+
 #if !STAT_MACROS_BROKEN
   struct stat sbuf;
   if (stat (file_name.to_str0 (), &sbuf) != 0)
@@ -67,12 +68,14 @@ is_file (String file_name)
   return !S_ISDIR (sbuf.st_mode);
 #endif
 
+
   if (FILE *f = fopen (file_name.to_str0 (), "r"))
     {
       fclose (f);
       return true;
     }
 
+  
   return false;
 }
 
@@ -120,29 +123,31 @@ File_path::find (String name) const
   File_name file_name (name);
   if (file_name.dir_[0] == DIRSEP && is_file (file_name.to_string ()))
     return file_name.to_string ();
-
-  for (int i = 0, n = size (); i < n; i++)
+  
+  for (int i = 0; i < dirs_.size (); i++)
     {
-      File_name dir = elem (i);
+      File_name file_name (name);
+      File_name dir = dirs_[i];
       file_name.root_ = dir.root_;
       dir.root_ = "";
-      file_name.dir_ = dir.to_string ();
+      if (file_name.dir_.is_empty ())
+       file_name.dir_ = dir.to_string ();
+      else if (!dir.to_string ().is_empty())
+       file_name.dir_ += ::to_string (DIRSEP) + dir.to_string ();
+       
       if (is_file (file_name.to_string ()))
        return file_name.to_string ();
     }
   return "";
 }
 
-/** Find a file.
-
-Seach in the current dir (DUH! FIXME?), in the construction-arg
-(what's that?, and in any other appended directory, in this order.
+/*
+  Try to find
 
-Search for NAME, or name without extension, or name with any of
-EXTENSIONS, in that order.
+    file.EXT,
 
-@return
-The file name if found, or empty string if not found. */
+  where EXT is from EXTENSIONS.
+*/
 String
 File_path::find (String name, char const *extensions[])
 {
@@ -161,6 +166,7 @@ File_path::find (String name, char const *extensions[])
          if (!find (file_name.to_string ()).is_empty ())
            break;
        }
+      
       /* Reshuffle extension */
       file_name = File_name (file_name.to_string ());
     }
@@ -185,11 +191,23 @@ String
 File_path::to_string () const
 {
   String s;
-  for (int i = 0, n = size (); i < n; i++)
+  for (int i = 0; i < dirs_.size (); i++)
     {
-      s = s + elem (i);
-      if (i < n - 1)
+      s = s + dirs_[i];
+      if (i < dirs_.size() - 1)
        s += ::to_string (PATHSEP);
     }
   return s;
 }
+
+void
+File_path::append (String str)
+{
+  dirs_.push (str);
+}
+
+void
+File_path::prepend (String str)
+{
+  dirs_.insert (str, 0);
+}
index be2268ec858c28643cc8287f67ba7c6377fa50c2..fb3e3ff13af246efcebe3abccd365647e750beca 100644 (file)
@@ -23,7 +23,6 @@ public:
   File_name (String);
 
   String to_string () const;
-  char const *to_str0 () const;
 };
 
 #endif /* FILE_NAME */
index 3c7cc264617ddd179cbe84e01a22a0bc0e62e75c..37a4b6c2b1b2e794b5e35ec5f6eba258a8a96da8 100644 (file)
    TODO: add a unix style PATH interface
 */
 
-class File_path : private Array<String>
+class File_path
 {
+  Array<String> dirs_; 
 public:
   Array<String> directories () const;
   String find (String name) const;
   String find (String name, char const *extensions[]);
   String to_string () const;
   bool try_append (String str);
-  void append (String str) { Array<String>::push (str); }
+  void append (String str);
   void parse_path (String);
-  void prepend (String str) { Array<String>::insert (str, 0); }
+  void prepend (String str);
 };
 
 #endif /* FILE_PATH */
index 5380c92a6908e53ebfaaebbbee8dbf1dc3698762..343bdb08c84c3ad28a1c29af3bd9c7b9d15115fe 100644 (file)
@@ -10,6 +10,7 @@
 #include "axis-group-engraver.hh"
 #include "hara-kiri-group-spanner.hh"
 #include "rhythmic-head.hh"
+#include "spanner.hh"
 
 class Hara_kiri_engraver : public Axis_group_engraver
 {