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>
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
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)