Ignore:
Timestamp:
Jul 8, 2010, 3:20:07 AM (11 years ago)
Author:
charles
Message:

(trunk libT) use the Mac client's speed formatter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/utils.c

    r10963 r10977  
    16461646tr_formatter_speed_Bps( char * buf, uint64_t bytes_per_second, size_t buflen )
    16471647{
    1648     formatter_get_size_str( &speed_units, buf, bytes_per_second, buflen );
     1648    const double K = speed_units.units[TR_FMT_KB].value;
     1649    double speed = bytes_per_second / K;
     1650
     1651    if( speed <= 999.95 ) /* 0.0 KB to 999.9 KB */
     1652        tr_snprintf( buf, buflen, "%.2f %s", speed, speed_units.units[TR_FMT_KB].name );
     1653    else {
     1654        speed /= K;
     1655        if( speed <= 99.995 ) /* 0.98 MB to 99.99 MB */
     1656            tr_snprintf( buf, buflen, "%.2f %s", speed, speed_units.units[TR_FMT_MB].name );
     1657        else if (speed <= 999.95) /* 100.0 MB to 999.9 MB */
     1658            tr_snprintf( buf, buflen, "%.1f %s", speed, speed_units.units[TR_FMT_MB].name );
     1659        else {
     1660            speed /= K;
     1661            tr_snprintf( buf, buflen, "%.1f %s", speed, speed_units.units[TR_FMT_GB].name );
     1662        }
     1663    }
     1664
    16491665    return buf;
    16501666}
Note: See TracChangeset for help on using the changeset viewer.