]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/file-path.cc
Run `make grand-replace'.
[lilypond.git] / flower / file-path.cc
index 0b1b979b6b3292c703ef138d9d1acd048a6f4b51..0177d40c9f70c3ff7f5b993b0ef3b79f084adfe8 100644 (file)
@@ -3,14 +3,12 @@
 
   source file of the Flower Library
 
-  (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 1997--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
   Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
 #include "file-path.hh"
 
-#include "std-string.hh"
-
 #include <cstdio>
 #include <cerrno>
 
@@ -36,24 +34,11 @@ File_path::directories () const
   return dirs_;
 }
 
-/*
-  TODO: use split_string.
-  
- */
-
 #include <algorithm>
 void
 File_path::parse_path (string p)
 {
-  ssize len;
-  while ((len = p.length ()))
-    {
-      ssize i = p.find (PATHSEP);
-      if (i == NPOS)
-       i = len;
-      append (p.substr (0, i));
-      p = p.substr (min (len, i + 1));
-    }
+  concat (dirs_, string_split (p, PATHSEP));
 }
 
 bool
@@ -79,6 +64,11 @@ is_file (string file_name)
 bool
 is_dir (string file_name)
 {
+  /*
+    canonicalize; in particular, trailing slashes should disappear.
+   */
+  file_name = File_name (file_name).to_string ();
+  
 #if !STAT_MACROS_BROKEN
   struct stat sbuf;
   if (stat (file_name.c_str (), &sbuf) != 0)