I was taking a look at this bug, I made some progress on it.
In UnixDirView.cpp first I added a function to display filesizes in a human readable format:
AnsiString TUnixDirView::FormatFileSize(__int64 size)
{
const __int64 B = 1;
const __int64 KB = 1024 * B;
const __int64 MB = 1024 * KB;
const __int64 GB = 1024 * MB;
if(size > GB)
return FormatFloat("0.## GB", size / GB);
else if(size > MB)
return FormatFloat("0.## MB", size / MB);
else if(size > KB)
return FormatFloat("0.## KB", size / KB);
else
return FormatFloat("0.## b", size);
}
Then I changed
TUnixDirView::GetDisplayInfo
case uvSize:
// expanded from ?: to avoid memory leaks
if (!File->IsDirectory)
{
Value = FormatFileSize(File->Size);
}
break;
But this
only affects the remote pane not the local pane. I couldn't for the life of me find where that was happening.
Later on, I found the
FormatBytes function in GUITools.cpp. If you add a reference to GUITools.h at the top of UnixDirView.cpp, you can use that function and ignore mine completely:
case uvSize:
// expanded from ?: to avoid memory leaks
if (!File->IsDirectory)
{
Value = FormatBytes(File->Size);
}
break;
I kept looking and I eventually found that the display for the local pane was governed by a Pascal Function FormatSize in
BaseUtils.pas. I edited those two functions to format the size in the same manner as FormatBytes.
function FormatSize(Size: Cardinal): string;
var
i: Integer;
p: Integer;
suffix: string;
begin
p := 0;
i := 3;
if Size < (100*1024) then begin {b}
suffix := ' B';
end else if Size < (100*1024*1024) then begin {KB}
Size := Cardinal(Round(Size / 1024));
suffix := ' KiB';
end else begin {MB}
Size := Cardinal(Round(Size / (1024 * 1024)));
suffix := ' MiB';
end;
Result := IntToStr(Size);
while i + p < Length(Result) do
begin
Insert(ThousandSeparator, Result, Length(Result) - (i + p)+ 1);
Inc(p);
INC(i, 3);
end;
Insert(Suffix, Result, Length(Result) + 1)
end; {FormatSize}
function FormatSize(Size: Int64): String;
var
i: Integer;
p: Integer;
suffix: string;
begin
p := 0;
i := 3;
if Size < (100*1024) then begin {b}
suffix := ' B';
end else if Size < (100*1024*1024) then begin {KB}
Size := Round(Size / 1024);
suffix := ' KiB';
end else begin {MB}
Size := Round(Size / (1024 * 1024));
suffix := ' MiB';
end;
Result := IntToStr(Size);
while i + p < Length(Result) do
begin
Insert(ThousandSeparator, Result, Length(Result) - (i + p)+ 1);
Inc(p);
Inc(i, 3);
end;
Insert(Suffix, Result, Length(Result) + 1)
end; {FormatSize}
Searching for "#,##0" brings up some other locations where the filesize should probably be edited. But when I edited those, I didn't see any change, so since I can't test that code, I left it alone.
I hope this helps - I decided I needed to kick myself and contribute something to Open Source.