Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2005-05-12 14:55:01


At 02:54 PM 5/12/2005, Peter Dimov wrote:
>Beman Dawes wrote:
>
>> status_flag status_imp( const char * path, system_error_type * ec )
>> {
>> struct stat path_stat;
>>
>> if ( ::stat( path, &path_stat ) != 0 )
>> {
>> if ( ec != 0 ) *ec = errno;
>> return ((errno == ENOENT) || (errno == ENOTDIR))
>> ? fs::not_found_flag : fs::error_flag;
>> }
>>
>> system_error_type result(0);
>
>status_flag result( 0 );

Oops! Right.

>>
>> if ( S_ISDIR( path_stat.st_mode ) ) result |= fs::directory_flag;
>> if ( S_ISREG( path_stat.st_mode ) ) result |= fs::file_flag;
>>
>> return result;
>> }
>
>This makes perfect sense; what changes did you expect from me? :-)

Seemed better to ask than guess:-)

One possible change would be to add, just before the final return:

     if ( ec != 0 ) *ec = 0;

But that seems gratuitous to me; the user can always set *ec = 0 before the
call to status() if desired.

--Beman


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