Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2005-03-31 06:46:12

On Wed, 30 Mar 2005 15:16:07 -0500, Beman Dawes wrote
> "Martin" <adrianm_at_[hidden]> wrote in message

Couple thoughts below....
> > I also had hopes for some new things that didn't appear in the new
> > implementation.
> > - non-throwing is_* functions. I find it very inconvenient and error prune
> > to
> > put try/catch around each is_directory call. Calling is_accessible before
> > every other is_* function is an option but not much easier and still
> > leaves a
> > risk for an exception if another process is accessing the file.
> If the is_* functions return false, rather than throwing, then
> testing for the negative of a is_* function becomes unreliable. Does
> !is_directory( "foo" ) mean that "foo" is a file, or is is just
> missing? The programmer would have to write exists("foo") &&
> is_accessible("foo") && !is_directory("foo").

Why not:

   enum exists_check { CHECK, NO_CHECK };
   bool is_directory( path p, exists_check = CHECK);

Always returns false if directory doesn't exist...

> That could be
> simplified by providing an is_file() function (as suggested by Jeff
> Garland recently), but then we have to define exactly what a file
> is. Is a socket a file? Is a device a file? Or what POSIX calls a
> "regular file"? How does that translate to Windows?

I think I already said this, but just to be sure:

> Is a socket a file?


>Is a device a file?


> Or what POSIX calls a "regular file"?


>How does that translate to Windows?

Since there are no simlinks is_file() == !is_directory().

> > - Why doesn't last_write_time return a boost::ptime
> That was a concious decision to limit coupling. That is, to avoid
> Boost libraries which are not part of TR1. I'd like the Boost
> version to be identical to what gets proposed to the standards
> committee, and unless Boost Date-Time gets proposed and accepted,
> that means it can't be used.

This can be trivially implemented in convenience functions since date-time has
added a from_time_t function for posix_time. Basically you just need a thin
veneer over the current functions:

     #include "boost/date_time/posix_time/conversion.hpp"
     //sorry can't think of a good function name....
     last_write_time_as_ptime( const path & ph )
        using boost::posix_time;
        return from_time_t(last_write_time( const path & ph ));

I'm not suggesting Beman add this to filesystem core -- just pointing out that
it can be done trivially with an add-on.


Boost list run by bdawes at, gregod at, cpdaniel at, john at