Boost logo

Boost :

From: Martin (adrianm_at_[hidden])
Date: 2004-03-21 06:01:08


I have used the filesystem library for some time now and I am really happy with
it.

In the CVS I noticed that it recently added relational operators and
an "equivalent" function.

To my surprice the relational operators are implemented in a non-portable way.
It only does a lexicographical compare! In the rationale it says:

"Programmers wishing to determine if two paths are "the same" must decide if
that means "the same representation" or "resolve to the same actual file or
directory", and choose the appropriate function accordingly."

In windows the path "file.cpp" is the same as "FILE.CPP" but not in posix. So
if I write portable code I need to do add a function like

bool eq_path(const path& path1, const path& path2) {
#if BOOST_POSIX
  return path1.string() == path2.string();
#else
  return boost::algorithm::iequals(path1.string(), path2.string());
#endif
}

In most of my cases the equivalent function is not an alternative since it
requires that both paths can be evaluted by the filesystem, i.e. paths must
exist and the parent of relative paths must be known.

---------------------------------------

Another minor question: Why does the "leaf()" member function return a string
and not a path?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk