示例#1
0
wxString DirectoriesPrefs::FormatSize(wxLongLong size)
{
    wxString sizeStr;

    /* wxLongLong contains no built-in conversion to double */
    double dSize = size.GetHi() * pow(2, 32);  // 2 ^ 32
    dSize += size.GetLo();

    if (size == -1L)
        sizeStr = _("Unable to determine");
    else {
        /* make it look nice, by formatting into k, MB, etc */
        if (size < 1024)
            sizeStr.sprintf("%ld bytes", size.GetLo());
        else if (size < 1024 * 1024) {
            sizeStr.sprintf("%.1f kB", dSize / 1024);
        }
        else if (size < 1024 * 1024 * 1024) {
            sizeStr.sprintf("%.1f MB", dSize / (1024 * 1024));
        }
        else {
            sizeStr.sprintf("%.1f GB", dSize / (1024 * 1024 * 1024));
        }
    }

    return sizeStr;
}
示例#2
0
wxString Internat::FormatSize(wxLongLong size)
{
    /* wxLongLong contains no built-in conversion to double */
    double dSize = size.GetHi() * pow(2.0, 32);  // 2 ^ 32
    dSize += size.GetLo();

    return FormatSize(dSize);
}