X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=flower%2Ffile-path.cc;h=0177d40c9f70c3ff7f5b993b0ef3b79f084adfe8;hb=5b4b0d6e9a197e8f9eb085b7c2ad78b8be3e5cfc;hp=0b1b979b6b3292c703ef138d9d1acd048a6f4b51;hpb=31568c504806f35aac420a394c9eab07abd9faa7;p=lilypond.git diff --git a/flower/file-path.cc b/flower/file-path.cc index 0b1b979b6b..0177d40c9f 100644 --- a/flower/file-path.cc +++ b/flower/file-path.cc @@ -3,14 +3,12 @@ source file of the Flower Library - (c) 1997--2006 Han-Wen Nienhuys + (c) 1997--2008 Han-Wen Nienhuys Jan Nieuwenhuizen */ #include "file-path.hh" -#include "std-string.hh" - #include #include @@ -36,24 +34,11 @@ File_path::directories () const return dirs_; } -/* - TODO: use split_string. - - */ - #include 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)