コード例 #1
0
static rc_t write_statistic( statistic_writer *writer, statistic *data,
                             uint64_t * written, bool show_progress )
{
    writer_ctx ctx;
    uint64_t count;

    ctx.writer = writer;
    ctx.rc = 0;
    ctx.progress = NULL;

    if ( show_progress )
    {
        make_progressbar( &ctx.progress );
        ctx.entries = data->entries;
        ctx.fract_digits = progressbar_calc_fract_digits( ctx.entries );
        ctx.n = 0;
    }

    count = foreach_statistic( data, write_cb, &ctx );

    if ( show_progress )
    {
        destroy_progressbar( ctx.progress );
        OUTMSG(( "\n" ));
    }

    if ( written != NULL ) *written = count;

    return ctx.rc;
}
コード例 #2
0
static uint8_t calc_fract_digits( const num_gen_iter *iter )
{
    uint8_t res = 0;
    uint64_t count;
    if ( num_gen_iterator_count( iter, &count ) == 0 )
    {
        res = progressbar_calc_fract_digits( count );
    }
    return res;
}
コード例 #3
0
rc_t write_output_file( KDirectory *dir, statistic * data,
                        const char * path, uint64_t * written )
{
    write_ctx wctx;
    rc_t rc;

    if ( written != NULL )
    {
        *written = 0;
    }
    wctx.out = NULL;
    wctx.pos = 0;
    wctx.lines = 0;
    rc = KDirectoryCreateFile ( dir, &wctx.out, false, 0664, kcmInit, path );
    if ( rc != 0 )
        LogErr( klogInt, rc, "KDirectoryCreateFile() failed\n" );
    else
    {
        char buffer[ 256 ];
        size_t num_writ;
        rc = string_printf ( buffer, sizeof buffer, &num_writ,
          "SPOTGROUP\tCYCLE\tNRead\tDIMER\tGC_CONTENT\tHP_RUN\tMaxQ\tQuality\tTOTAL\tMISMATCH\n" );
        if ( rc == 0 )
        {
            size_t f_writ;
            rc = KFileWrite ( wctx.out, wctx.pos, buffer, num_writ, &f_writ );
            if ( rc == 0 )
            {
                if ( written != NULL ) *written = f_writ;
                wctx.pos += f_writ;

                make_progressbar( &wctx.progress );
                wctx.entries = data->entries;
                wctx.fract_digits = progressbar_calc_fract_digits( wctx.entries );

                foreach_statistic( data, write_to_file_cb, &wctx );

                destroy_progressbar( wctx.progress );
                OUTMSG(( "\n" ));

                KFileRelease ( wctx.out );
                if ( written != NULL )
                {
                    *written = wctx.lines;
                }
            }
        }
    }
    return rc;
}