Boost logo

Boost :

From: Ross Smith (r-smith_at_[hidden])
Date: 2002-03-22 10:30:04


Beman Dawes wrote:
>
> At 05:42 AM 3/21/2002, Ross Smith wrote:
>
> >-- Dividing everything into "is_directory()" vs "is_file()" doesn't work
> >on Unix, where there are any number of other things a file system object
> >might be (devices, pipes, etc.).
>
> Hum... That isn't my understanding. "Everything in the UNIX system is a
> file." First sentence of Chapter 2, The File System, Kernighan and Pike's
> The UNIX Programming Environment. Section 2.7 makes it very clear they view
> devices as files.

But if you're using "file" in that very general sense, then it also
includes directories, and the implementation of is_file() would be
"return true;".

Files-in-the-general-sense on Unix are normally thought of as being
divided into directories, ordinary files (files-in-the-narrow-sense),
and special files (devices, pipes, etc.). I don't think, and I don't
think most Unix users think, of the distinction between directories and
everything else as being more fundamental than that between ordinary and
special files. I think you need to provide a way of distinguishing
between those three cases. (On Windows, "special files" would be the
likes of "LPT1:".)

I use three functions -- is_directory(), is_file(), is_special() --
exactly one of which will always be true for any existing
file-in-the-general-sense. (Also is_symlink(), which is a subset of
is_file().)

(I use "file" to mean "ordinary file", and FSO (for "file system
object") for file-in-the-general-sense. Adopting something like that
might be useful, since the multiple different meanings of "file" seem to
be confusing us.)

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