|
Boost : |
From: Powell, Gary (powellg_at_[hidden])
Date: 2004-02-03 12:48:58
Beman wrote:
How should size( "foo" ) behave if "foo" is a directory?
1) Throw. The function should be renamed file_size().
2) Return 0. Directories don't strictly speaking have a size.
3) Return the number of entries in the directory. Directories are really
just containers; so of course they have a size.
-------------------------------------------------
Gary Replies:
#1, while an OS can implement directories as a file of information, I think its conceptually wrong for this function to ask for its "size". When iterating through a file system you should first guarantee that the file name is a file and not that of a sub directory.
The 4th answer would be to return the total size of all the files within the directory. But I think that's also conceptually confusing as well.
Yours,
-Gary-
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk