Changeset 11382


Ignore:
Timestamp:
Nov 3, 2010, 4:59:24 PM (11 years ago)
Author:
charles
Message:

(trunk libT) #3712 "transmission-show's file list should be sorted alphabetically" -- done.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/utils/show.c

    r11263 r11382  
    8686}
    8787
     88static int
     89compare_files_by_name( const void * va, const void * vb )
     90{
     91    const tr_file * a = *(const tr_file**)va;
     92    const tr_file * b = *(const tr_file**)vb;
     93    return strcmp( a->name, b->name );
     94}
     95
    8896static void
    8997showInfo( const tr_info * inf )
     
    9199    int i;
    92100    char buf[128];
     101    tr_file ** files;
    93102    int prevTier = -1;
    94103
     
    135144
    136145    printf( "\nFILES\n\n" );
     146    files = tr_new( tr_file*, inf->fileCount );
    137147    for( i=0; i<(int)inf->fileCount; ++i )
    138         printf( "  %s (%s)\n", inf->files[i].name, tr_formatter_size_B( buf, inf->files[i].length, sizeof( buf ) ) );
     148        files[i] = &inf->files[i];
     149    qsort( files, inf->fileCount, sizeof(tr_file*), compare_files_by_name );
     150    for( i=0; i<(int)inf->fileCount; ++i )
     151        printf( "  %s (%s)\n", files[i]->name, tr_formatter_size_B( buf, files[i]->length, sizeof( buf ) ) );
     152    tr_free( files );
    139153}
    140154
Note: See TracChangeset for help on using the changeset viewer.