1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-12 09:25:03 +00:00

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

This commit is contained in:
Charles Kerr 2010-11-03 16:59:24 +00:00
parent 2060f72f22
commit d34149f810

View file

@ -85,11 +85,20 @@ parseCommandLine( int argc, const char ** argv )
return 0;
}
static int
compare_files_by_name( const void * va, const void * vb )
{
const tr_file * a = *(const tr_file**)va;
const tr_file * b = *(const tr_file**)vb;
return strcmp( a->name, b->name );
}
static void
showInfo( const tr_info * inf )
{
int i;
char buf[128];
tr_file ** files;
int prevTier = -1;
/**
@ -134,8 +143,13 @@ showInfo( const tr_info * inf )
**/
printf( "\nFILES\n\n" );
files = tr_new( tr_file*, inf->fileCount );
for( i=0; i<(int)inf->fileCount; ++i )
printf( " %s (%s)\n", inf->files[i].name, tr_formatter_size_B( buf, inf->files[i].length, sizeof( buf ) ) );
files[i] = &inf->files[i];
qsort( files, inf->fileCount, sizeof(tr_file*), compare_files_by_name );
for( i=0; i<(int)inf->fileCount; ++i )
printf( " %s (%s)\n", files[i]->name, tr_formatter_size_B( buf, files[i]->length, sizeof( buf ) ) );
tr_free( files );
}
static size_t