util/configutil.cc
/// Check by reading a byte from the named file, or verifying
/// that the directory may be enumerated and is *non-empty*.
/// Returns if readable; throws an exception if not.
///
Check by reading a byte from the named file, or verifying
that the directory may be enumerated and is *non-empty*.
Returns if readable; throws an exception if not.
Check by reading a byte from the named file or verifying that the directory may be enumerated and is * non - empty * . Returns if readable ; throws an exception if not .
bool verify_readable( const boost::filesystem::path &p )
{
    using namespace boost::filesystem;
    if (exists(p)) {
        if (is_directory(p)) {
            for (directory_entry& x : directory_iterator(p)) {
                if (verify_readable(x.path())) { return true; }
            }
            throw invalid_argument(string("No readable files in ")+p.native());
        }
        else if (is_regular_file(p)) {
            FILE *sfile = fopen(p.c_str(),"r");
            if (sfile) {
                fclose(sfile);
                return true;
            }
            throw invalid_argument(string("Cannot read file ")+p.native());
        }
        else {
            throw invalid_argument("Cannot verify path "+ p.native()); 
        }
    } else {
        throw invalid_argument(string("No such path ")+p.native());
    }
    return false;
}
bool verify_readable ( const boost :: filesystem :: path & p ) { using namespace boost :: filesystem ; if ( exists ( p ) ) { if ( is_directory ( p ) ) { for ( directory_entry & x : directory_iterator ( p ) ) { if ( verify_readable ( x . path ( ) ) ) { return true ; } } throw invalid_argument ( string ( " " ) + p . native ( ) ) ; } else if ( is_regular_file ( p ) ) { FILE * sfile = fopen ( p . c_str ( ) , " " ) ; if ( sfile ) { fclose ( sfile ) ; return true ; } throw invalid_argument ( string ( " " ) + p . native ( ) ) ; } else { throw invalid_argument ( " " + p . native ( ) ) ; } } else { throw invalid_argument ( string ( " " ) + p . native ( ) ) ; } return false ; }
Check by reading a byte from the named file, or verifying
that the directory may be enumerated and is *non-empty*.
Check by reading a byte from the named file or verifying that the directory may be enumerated and is * non - empty * .
// try opening and finding any readable file // try reading a byte // symlink?