Example #1
0
static rc_t report_references( const VDBManager *vdb_mgr, VFSManager * vfs_mgr,
                               const char * spec, bool extended )
{
    const String * resolved = NULL;
    rc_t rc = resolve_accession( vfs_mgr, spec, &resolved );
    if ( rc == 0 && resolved != NULL )
    {
        rc = KOutMsg( "resolved into '%S'\n", resolved );
        if ( rc == 0 )
        {
            int path_type = ( VDBManagerPathType ( vdb_mgr, "%s", spec ) & ~ kptAlias );
            switch( path_type )
            {
            case kptDatabase :
                rc = report_ref_database( vdb_mgr, vfs_mgr, spec, extended );
                break;

            case kptTable    :
                KOutMsg( "cannot report references on a table-object\n" );
                rc = RC ( rcApp, rcNoTarg, rcAccessing, rcParam, rcInvalid );
                (void)LOGERR( klogErr, rc, "cannot report references on a table-object" );
                break;

            default          :
                KOutMsg( "the given object is not a vdb-database\n" );
                rc = RC ( rcApp, rcNoTarg, rcAccessing, rcParam, rcInvalid );
                (void)LOGERR( klogErr, rc, "the given object is not a vdb-database" );
                break;
            }
        }
        StringWhack ( resolved );
    }
    return rc;
}
Example #2
0
static rc_t report_references( const VDBManager *vdb_mgr, VFSManager * vfs_mgr, const char * spec,
                               bool extended )
{
    rc_t rc = KOutMsg( "\nreporting references of '%s'\n", spec );
    if ( rc == 0 )
    {
        VPath * path = NULL;
        const VPath * local_cache = NULL;
        const KFile * remote_file = NULL;
        rc = VFSManagerResolveSpec ( vfs_mgr, spec, &path, &remote_file, &local_cache, true );
        if ( rc != 0 )
        {
            (void)LOGERR( klogErr, rc, "cannot resolve spec via VFSManager" );
        }
        else
        {
            char buffer[ 4096 ];
            size_t num_read;
            rc = VPathReadPath ( path, buffer, sizeof buffer, &num_read );
            if ( rc != 0 )
            {
                (void)LOGERR( klogErr, rc, "cannot read path from vpath" );
            }
            else
            {
                rc = KOutMsg( "resolved into '%s'\n", buffer );
                if ( rc == 0 )
                {
                    int path_type = ( VDBManagerPathType ( vdb_mgr, "%s", buffer ) & ~ kptAlias );
                    switch( path_type )
                    {
                        case kptDatabase : rc = report_ref_database( vdb_mgr, vfs_mgr, buffer, extended );
                                           break;

                        case kptTable    : rc = KOutMsg( "cannot report references on a table-object\n" );
                                           break;

                        default          : rc = KOutMsg( "the given object is not a vdb-database\n" );
                                           break;
                    }
                }
            }
            KFileRelease( remote_file );
            VPathRelease ( local_cache );
            VPathRelease ( path );
        }
    }
    return rc;
}