[ros-bugs] [Bug 6294] WIP: A file's size in bytes is not displayed.

ReactOS.Bugzilla at reactos.org ReactOS.Bugzilla at reactos.org
Mon Oct 17 22:23:40 UTC 2011


http://www.reactos.org/bugzilla/show_bug.cgi?id=6294





--- Comment #7 from Carlo Bramix <carlo.bramix at libero.it>  2011-10-17 22:23:39 CET ---
> How does the code breaks files larger than 2GB? Windows and ReactOS returns the
> same number: 2.82 GB (3,033,585,664 bytes)
> 

Well,

1) In your original patch, you implemented a FormatBytes() function that
receives an integer as first parameter. Later in the patch you did a
"swprintf(strfrmt, L"%d", numb);" which actually breaks files larger than 2GB.

2) User "chamel" posted a modified patch with this defect fixed: now
FormatBytes() function receives a "long long int" parameter and the formatter
has been changed to L"%lld". In my opinion this is not completely correct yet,
it should receive a PLARGE_INTEGER instead, although it is working in the way
he did.

3) I do not think it is a good idea to remove by hand the final decimal part in
that manner, especially if you think that this stuff depends by selected locale
and it may not be 3 chars. It is better to leave this task elsewhere by
providing our desidered formatting information to GetNumberFormat().

4) As consequence of point (3), it is better to not use fixed size buffers if
possible, but it would be more correct to let GetNumberFormat() to return the
amount of chars for holding the formatted string, allocate the string (in the
heap or in the stack) and then doing the conversion.

5) Since this stuff is derived from the usage of StrFormatByteSize(), it is
much more logical to make a function that acts like this one, that internally
calls StrFormatByteSize() with all other things and finally returns the well
formatted string. Sorry, but things like "swprintf(wstr, L"%s (%s %s)",
wstr,..." without controls makes me a bit sick...

6) This is not a defect, but just a question of coding style that comes from my
experience of software engineer: you can write "numb" but it would be better to
write as variable name something like "SizeOfFile" or something that explains
the purpose. In an enormous project like ReactOS, there could be hundred or
perhaps thousand of people that can look the source. It's better to write
something easier to understand.

Of course, this is just my personal opinion.


-- 
Configure bugmail: http://www.reactos.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.



More information about the Ros-bugs mailing list