|
Boost : |
From: Ross Smith (r-smith_at_[hidden])
Date: 2002-03-08 18:05:12
Jason Stewart wrote:
>
> I agree with this. Trying to make drives and UNC names appear like
> directories seems fraught with problems. How about the other approach.
> Instead of a single root, you could introduce the concept of volumes and
> each volume has a root. On UNIX there would only be one volume. On Windows
> there would be, i.e., A:, C:, \\somecomputer\share, etc.
My solution to this situation in my own library was to have a FileSystem
class, whose objects represent mounted filesystems. There's a function
(static FileSystem::list()) to enumerate all the physical f/ss on the
system, and the FileSystem object has an is_root() function that
indicates whether it's the root of a logical f/s; if is_root() is false,
then the f/s's root can be reached by directory traversal from another
f/s.
On Unix, only the f/s mounted as / has is_root() set; all other f/ss are
mounted somewhere in the directory tree and is_root() is false. On
Windows, FileSystem::list() would enumerate the available drive letters,
and all of them would have is_root() set. (Well, actually I think some
recent versions of Windows support Unix-style mount points, but you get
the idea.)
On the other hand, this thread has gone some way to persuading me that
using the Desktop as the one-and-only root on Windows does have its
merits.
(Looking at my code, I just realised my implementation of
FileSystem::list() still uses the original ugly hack involving
popen("df"). Memo to self: Must Fix This.)
-- Ross Smith ...................................... Auckland, New Zealand r-smith_at_[hidden] .................................................... "We need a new cosmology. New gods. New sacraments. Another drink." -- Patti Smith
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk