Changeset 3977


Ignore:
Timestamp:
Nov 26, 2007, 7:10:53 PM (15 years ago)
Author:
livings124
Message:

get last commit building

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/stats.c

    r3976 r3977  
    107107    tr_free( str );
    108108
    109     tr_BencFree( &top );
     109    tr_bencFree( &top );
    110110}
    111111
  • trunk/macosx/NSStringAdditions.h

    r3886 r3977  
    3131
    3232+ (NSString *) stringForFileSize: (uint64_t) size;
    33 + (NSString *) stringForLargeFileSizeGigs: (uint64_t) gigs bytes: (uint64_t) bytes;
    3433
    3534+ (NSString *) stringForSpeed: (float) speed;
  • trunk/macosx/NSStringAdditions.m

    r3886 r3977  
    11/******************************************************************************
    2  * $Id: StringAdditions.m 2869 2007-08-19 03:03:28Z livings124 $
     2 * $Id$
    33 *
    44 * Copyright (c) 2005-2007 Transmission authors and contributors
     
    4040+ (NSString *) stringForFileSize: (uint64_t) size
    4141{
    42     [self stringForLargeFileSizeGigs: size / 1073741824 bytes: size % 1073741824];
    43 }
     42    if (size < 1024)
     43        return [NSString stringWithFormat: NSLocalizedString(@"%lld bytes", "File size"), size];
    4444
    45 + (NSString *) stringForLargeFileSizeGigs: (uint64_t) gigs bytes: (uint64_t) bytes
    46 {
    4745    float convertedSize;
    4846    NSString * unit;
    49     if (gigs == 0)
     47    if (size < 1048576)
    5048    {
    51         if (bytes < 1024)
    52             return [NSString stringWithFormat: NSLocalizedString(@"%lld bytes", "File size"), bytes];
    53         else if (bytes < 1048576)
    54         {
    55             convertedSize = bytes / 1024.0;
    56             unit = NSLocalizedString(@"KB", "File size");
    57         }
    58         else
    59         {
    60             convertedSize = bytes / 1048576.0;
    61             unit = NSLocalizedString(@"MB", "File size");
    62         }
     49        convertedSize = size / 1024.0;
     50        unit = NSLocalizedString(@"KB", "File size");
     51    }
     52    else if (size < 1073741824)
     53    {
     54        convertedSize = size / 1048576.0;
     55        unit = NSLocalizedString(@"MB", "File size");
     56    }
     57    else if (size < 1099511627776.0)
     58    {
     59        convertedSize = size / 1073741824.0;
     60        unit = NSLocalizedString(@"GB", "File size");
    6361    }
    6462    else
    6563    {
    66         if (gigs < 1024)
    67         {
    68             convertedSize = (float)gigs + bytes / 1073741824.0;
    69             unit = NSLocalizedString(@"GB", "File size");
    70         }
    71         else
    72         {
    73             convertedSize = gigs / 1024.0;
    74             unit = NSLocalizedString(@"TB", "File size");
    75         }
     64        convertedSize = size / 1099511627776.0;
     65        unit = NSLocalizedString(@"TB", "File size");
    7666    }
    7767   
  • trunk/macosx/StatsWindowController.m

    r3915 r3977  
    8080    tr_getSessionStats(fLib, &statsSession);
    8181   
    82     [fUploadedField setStringValue: [NSString stringForLargeFileSizeGigs: statsSession.uploadedGigs bytes: statsSession.uploadedBytes]];
    83     [fUploadedAllField setStringValue: [[NSString stringForLargeFileSizeGigs: statsAll.uploadedGigs bytes: statsAll.uploadedBytes]
     82    [fUploadedField setStringValue: [NSString stringForFileSize: statsSession.uploadedMiB]];
     83    [fUploadedAllField setStringValue: [[NSString stringForFileSize: statsAll.uploadedMiB]
    8484                                        stringByAppendingString: NSLocalizedString(@" total", "stats total")]];
    8585   
    86     [fDownloadedField setStringValue: [NSString stringForLargeFileSizeGigs: statsSession.downloadedGigs
    87                                         bytes: statsSession.downloadedBytes]];
    88     [fDownloadedAllField setStringValue: [[NSString stringForLargeFileSizeGigs: statsAll.downloadedGigs
    89         bytes: statsAll.downloadedBytes] stringByAppendingString: NSLocalizedString(@" total", "stats total")]];
     86    [fDownloadedField setStringValue: [NSString stringForFileSize: statsSession.downloadedMiB]];
     87    [fDownloadedAllField setStringValue: [[NSString stringForFileSize: statsAll.downloadedMiB]
     88                                            stringByAppendingString: NSLocalizedString(@" total", "stats total")]];
    9089   
    9190    [fRatioField setStringValue: [NSString stringForRatio: statsSession.ratio]];
Note: See TracChangeset for help on using the changeset viewer.