From: Jason Stewart (res0054p_at_[hidden])
Date: 2002-01-24 07:39:22
>I think on unix drive() can sensibly return '/' (I found that useful
>in some cases). Case-sensitivity needs to be a runtime flag though,
>on my PC I use a mixture of file systems that are both case sensitive
>and insensitive, and even needs to manipulate pathnames that are
>intended for other systems.
Having the Drive function return '/' seems would break some things. For
assert(path.Drive() + path.Directory() == path.Get());
However, I do see your point about having the case sensitivity being a
runtime option. I guess it could be a template parameter where the default
for windows would be no and for unix would be yes.
>Probably every man, woman and their pet yak have written both
>pathname parsing and directory manipulation
>(creation/iterating/removal) classes, and probably most people (me
>including) combined the two.
Yes, I read somewhere that the favorite indoor sport of programmers is
writing string classes (this was before the STL), maybe path/directory
handling is the second.
>In a purest sense the concept of a pathname (that can be broken up
>into components and have those components easily modified) should be
>separate from the file-system object the pathname refers to.
In my experience it was very helpful to separate Path and File name
handling. Otherwise you have an ambiguity when you try to create a pathname
without a trailing slash. I found myself always adding an extra slash to
force it to be a pathname (the class also removes duplicate slashes).
In my classes the Pathname and Filename do no actually file or directory
manipulation (the only possible exception being Exists). Instead, I have a
FileSystem namespace that attempts to hide most of the differences between
platforms. Many of the functions are just wrappers that accept Filename or
Pathname objects. However, there are a few additions, such as:
SaveDirectory - Changes to the given directory and restores the current
working directory when it exits.
AutoDelete - Takes one or more files/directories and deletes
them when it goes out of scope.
Useful for cleaning up temporaries.
Delete(Pathname&) - Deletes a directory (including, optionally,
MakeDirectory - Optionally makes more than one directory
DirectoryIterator - Recurses directories (similar to dir_it)
>I also think 'pathname' should come in char and wchar_t flavours,
>with both versions supporting conversion to const char* so it can be
>used with fstream/filebuf.
That is one area that mine don't handle. I have not previously needed the
wchar_t type so I've ignored it. It should be fairly easy to add that support.
My classes support conversion to basic_string which can then be converted
to const char*. It might be convenient to support both conversions though.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk