Opened 18 years ago

Last modified 17 years ago

#1503 closed Patch

Implement friendly byte counts

Reported by: elsapo Owned by:
Priority: normal Component: FileZilla Server
Keywords: Cc: elsapo, jarcand, Tim Kosse
Component version: Operating system type:
Operating system version:

Description

Code to display, eg, "200000" as "200,000", and code to
alternatively display it as "195Kb" (it switches on an
option boolean which is of course never set, as
FileZilla Server currently does not have such an option).

This is to implement my RFE [ 1558084 ] Comma-separated
byte counts

http://sourceforge.net/tracker/index.php?func=detail&aid=1558084&group_id=21558&atid=372244

Attachments (1)

filezilla_server_numeric_formatting.zip (3.7 KB ) - added by elsapo 18 years ago.
Zip (4Kb) of source files

Download all attachments as: .zip

Change History (5)

by elsapo, 18 years ago

Zip (4Kb) of source files

comment:1 by elsapo, 18 years ago

In Interface/MainFrm.cpp
in method CMainFrame::ParseStatus
Change from current code

....str.Format("%I64d bytes received", m_nRecvCount);

to new code

....str.Format("%s bytes received", GetByteCount(m_nRecvCount));

/

  • @brief Formats a count as a string *
  • @param [in] number to format
  • @return Size string with inserted commas, or with size suffix
  • @todo Can't handle > terabyte filesizes. *
  • If the UseShortSize option is enabled: *
  • GetByteCount(500) = "500"
  • GetByteCount(1024) = "1,024"
  • GetByteCount(12000) = "12,000"
  • GetByteCount(200000) = "200,000" *
  • If the UseShortSize option is not enabled: *
  • GetByteCount(500) = "500b"
  • GetByteCount(1024) = "1Kb"
  • GetByteCount(12000) = "1.7Kb"
  • GetByteCount(200000) = "195Kb" */

static CString GetByteCount(_int64 count)
{

bool UseShortSize = false; @todo make option
if (UseShortSize)

return MakeShortSize(count); eg, "200,000"

else

return MakeLongSize(count); eg, "195Kb"

}

I'm attaching a zip of files implementing these two
functions. One file implements MakeShortSize and
MakeLongSize, and the other file implements Win32 locality
formatting.

comment:2 by elsapo, 18 years ago

(I didn't do this as a cvs patch because I am unable to
compile the cvs code; I'm sorry, but I've tried hard before,
and I know I cannot compile it.)

(So I made a test project to run the attached codefiles and
sanity check them -- but they're almost all code that I've
previously tested because it is currently in use in another
sourceforge project.)

comment:3 by jarcand, 18 years ago

Great work on the patch elsapo, however I think you might
have inverted two comments. What I mean is the
GetByteCount function should read:

static CString GetByteCount(_int64 count)
{

bool UseShortSize = false; @todo make option
if (UseShortSize)

return MakeShortSize(count); eg, "195Kb"

else

return MakeLongSize(count); eg, "200,000"

}

Instead of:

static CString GetByteCount(_int64 count)
{

bool UseShortSize = false; @todo make option
if (UseShortSize)

return MakeShortSize(count); eg, "200,000"

else

return MakeLongSize(count); eg, "195Kb"

}

(Note the two comments next to MarkShortSize and MakeLongSize.)

Obviously not a big issue, but I thought it should be
corrected before the patch is applied.

Anyways, keep up the great work.

Note: See TracTickets for help on using tickets.