Boost logo

Boost :

From: Jan Langer (jan_at_[hidden])
Date: 2002-03-06 08:08:33


On Tue, 5 Mar 2002, Beman Dawes wrote:
> >>template< typename CharT >
> >>std::basic_string<CharT> root_directory();
> >
> >why do we need this function. i think something like a
> >hierarchy_iterator would solve this far better.
>
>I was trying to avoid a specific hierarchy_iterator by saying that a
>regular directory_iterator acted like a hierarchy_iterator if given a
>special argument. I guess the name root_directory() is confusing.
>
> > eg. if i want to write
> >something to the root directory. it would not be allowed on win32. but
> >if i call directory_iterator (root_directory ()) it fits for win32
> >("c:") but not for posix ("/bin").
> >a hierarchy_iterator however returns "/" on posix and "c:" on win32.
>
>I was assuming directory_iterator( root_directory() ) would return all the
>directory_entry's in "/" for POSIX, and a:,b:,c:, etc for win32.

yes, but this is not what most users would expect. i think posix's '/'
corresponds to win's 'c:' and posix's '/bin' corresponds to wins
'c:\Windows\'. of course i mean only the level in the hierarchy.

if i call erase (*directory_iterator (root_directory ())) i expect that
on posix it tries to delete /bin and on windows
a:/firstfileonfloppy.txt. this behaviour can be achieved by a
hierarchy_iterator in a much clearer way.

> >it would be sufficent if we overload compose for a reasonable number of
> >arguments (5?).
>
>I'm not sure. That might be OK. It really gets hairy to do it
>portably. What POSIX and Windows do with "/" can take four or more
>separate delimiters on systems. What you are composing impacts the choice
>of delimiter. So composing a directory path is different from composing a
>file path. Bah!

but why does this influence the need of a separate path-class. if we
have a function compose doing lots of expensive parsing or system calls
on some systems or a member function of a class doing the same things
does not really matter. or i did not understand your statement
correctly.

-- 
jan langer ... jan_at_[hidden]
"pi ist genau drei"

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