Boost logo

Boost :

From: Christoph Ludwig (cludwig_at_[hidden])
Date: 2004-02-03 04:00:38


On Mon, Feb 02, 2004 at 12:14:47PM -0500, Edward Diener wrote:
> Beman Dawes wrote:
> > How should size( "foo" ) behave if "foo" is a directory?
> >
> > 1) Throw. The function should be renamed file_size().
> >
[...]
>
> I agree with your conclusion. Asking for the file_size of a directory is
> just wrong.

What's wrong about it?

Example: If I do a "ls -lh" in my boost directory (Linux, Reiser FS),
the first two lines I get are:

drwxr-xr-x 31 cludwig users 3544 2003-11-27 11:06 boost
-r-xr-xr-x 1 cludwig users 298 2003-11-27 11:06 boost-build.jam

The system tells me that the special file containing the directory
entries for the subdir "boost" occupies 3,5 KByte. I also checked the
output of ls on a Solaris machine (with an ufs filesystem, I assume)
and on a FAT32 filesystem. There the situation is similar; the only
difference is that the reported size is always a multiple of the file
system's block size.

I don't know about other filesystems, but in the examples above it
makes perfectly sense to ask for the size of a directory (rather than
the sum of the size of its content).

Beman's list of options has therefore to be appended:

4) Return the size of the special file containing the directory
   information.

Provided it can be implemented on other systems, too, this would be
the most natural behaviour in my opinion.

Regards

Christoph

-- 
http://www.informatik.tu-darmstadt.de/TI/Mitarbeiter/cludwig.html
LiDIA: http://www.informatik.tu-darmstadt.de/TI/LiDIA/Welcome.html

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