Пример #1
0
static rc_t vdb_info_1( VSchema * schema, dump_format_t format, const VDBManager *mgr,
                        const char * acc_or_path, const char * table_name )
{
    rc_t rc = 0;
    vdb_info_data data;

    memset( &data, 0, sizeof data );
    data.s_platform = PT_NONE;
    data.acc = acc_or_path;

    /* #1 get path-type */
    data.s_path_type = get_path_type( mgr, acc_or_path );

    if ( data.s_path_type[ 0 ] == 'D' || data.s_path_type[ 0 ] == 'T' )
    {
        rc_t rc1;

        /* #2 fork by table or database */
        switch ( data.s_path_type[ 0 ] )
        {
            case 'D' : vdb_info_db( &data, schema, mgr ); break;
            case 'T' : vdb_info_tab( &data, schema, mgr ); break;
        }

		/* try to resolve the path locally */
        rc1 = resolve_accession( acc_or_path, data.path, sizeof data.path, false ); /* vdb-dump-helper.c */
        if ( rc1 == 0 )
            data.file_size = get_file_size( data.path, false );
		else
		{
			/* try to resolve the path remotely */
			rc1 = resolve_accession( acc_or_path, data.path, sizeof data.path, true ); /* vdb-dump-helper.c */
			if ( rc1 == 0 )
			{
				data.file_size = get_file_size( data.path, true );
				/* try to find out the cache-file */
				rc1 = resolve_cache( acc_or_path, data.cache, sizeof data.cache ); /* vdb-dump-helper.c */
				if ( rc1 == 0 )
				{
					/* try to find out cache completeness */
					check_cache_comleteness( data.cache, &data.cache_percent, &data.bytes_in_cache );
				}
			}
		}
		
        switch ( format )
        {
            case df_xml  : rc = vdb_info_print_xml( &data ); break;
            case df_json : rc = vdb_info_print_json( &data ); break;
            case df_csv  : rc = vdb_info_print_sep( &data, ',' ); break;
            case df_tab  : rc = vdb_info_print_sep( &data, '\t' ); break;
            case df_sql  : rc = vdb_info_print_sql( table_name, &data ); break;
            default     : rc = vdb_info_print_dflt( &data ); break;
        }
    }

    return rc;
}
Пример #2
0
static rc_t vdb_info_1( VSchema * schema, dump_format_t format, const VDBManager *mgr,
                        const char * acc_or_path, const char * table_name )
{
    rc_t rc = 0;
    vdb_info_data data;

    memset( &data, 0, sizeof data );
    data.s_platform = PT_NONE;
    data.acc = acc_or_path;

    /* #1 get path-type */
    data.s_path_type = get_path_type( mgr, acc_or_path );

    if ( data.s_path_type[ 0 ] == 'D' || data.s_path_type[ 0 ] == 'T' )
    {
        rc_t rc1;

        /* #2 fork by table or database */
        switch ( data.s_path_type[ 0 ] )
        {
            case 'D' : vdb_info_db( &data, schema, mgr ); break;
            case 'T' : vdb_info_tab( &data, schema, mgr ); break;
        }

        rc1 = resolve_accession( acc_or_path, data.path, sizeof data.path, false );
        if ( rc1 == 0 )
            data.file_size = get_file_size( data.path );

        switch ( format )
        {
            case df_xml  : rc = vdb_info_print_xml( &data ); break;
            case df_json : rc = vdb_info_print_json( &data ); break;
            case df_csv  : rc = vdb_info_print_sep( &data, ',' ); break;
            case df_tab  : rc = vdb_info_print_sep( &data, '\t' ); break;
            case df_sql  : rc = vdb_info_print_sql( table_name, &data ); break;
            default     : rc = vdb_info_print_dflt( &data ); break;
        }
    }

    return rc;
}