[GB.FORM]
* NEW: Format files sizes with two decimals. [GB.UTIL] * BUG: File.FormatSize() now takes an optional argument that allows to format the size in binary format (1K = 1024) instead of decimal format (1K = 1000). git-svn-id: svn://localhost/gambas/trunk@6718 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
3dc8d48deb
commit
5468b4c704
4 changed files with 25 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
||||||
# Gambas Project File 3.0
|
# Gambas Project File 3.0
|
||||||
# Compiled with Gambas 3.6.0
|
# Compiled with Gambas 3.6.90
|
||||||
Title=More controls for graphical components
|
Title=More controls for graphical components
|
||||||
Startup=FDocumentView
|
Startup=FDocumentView
|
||||||
Version=3.6.90
|
Version=3.6.90
|
||||||
|
|
|
@ -45,11 +45,11 @@ Public Sub GetFileSize(iSize As Long) As String
|
||||||
If iSize < 1024 Then
|
If iSize < 1024 Then
|
||||||
Return Subst(("&1 B"), CStr(iSize))
|
Return Subst(("&1 B"), CStr(iSize))
|
||||||
Else If iSize < 1048576 Then
|
Else If iSize < 1048576 Then
|
||||||
Return Subst(("&1 KiB"), Format(iSize / 1024, "0.#"))
|
Return Subst(("&1 KiB"), Format(iSize / 1024, "0.##"))
|
||||||
Else If iSize < 1073741824 Then
|
Else If iSize < 1073741824 Then
|
||||||
Return Subst(("&1 MiB"), Format(iSize / 1048576, "0.#"))
|
Return Subst(("&1 MiB"), Format(iSize / 1048576, "0.##"))
|
||||||
Else
|
Else
|
||||||
Return Subst(("&1 GiB"), Format(iSize / 1073741824, "0.#"))
|
Return Subst(("&1 GiB"), Format(iSize / 1073741824, "0.##"))
|
||||||
Endif
|
Endif
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
|
@ -38,7 +38,7 @@ C
|
||||||
FormatSize
|
FormatSize
|
||||||
M
|
M
|
||||||
s
|
s
|
||||||
(Size)l
|
(Size)l[(Binary)b]
|
||||||
#Shell
|
#Shell
|
||||||
|
|
||||||
C
|
C
|
||||||
|
|
|
@ -2,16 +2,28 @@
|
||||||
|
|
||||||
Export
|
Export
|
||||||
|
|
||||||
Static Public Sub FormatSize(Size As Long) As String
|
Static Public Sub FormatSize(Size As Long, Optional {Binary} As Boolean) As String
|
||||||
|
|
||||||
If Size < 1000 Then
|
If {Binary} Then
|
||||||
Return Subst("&1 B", CStr(Size))
|
If Size < 1024 Then
|
||||||
Else If Size < 1000000 Then
|
Return Subst(("&1 B"), CStr(Size))
|
||||||
Return Subst("&1 KiB", Format(Size / 1000, "#.#"))
|
Else If Size < 1048576 Then
|
||||||
Else If Size < 1000000000 Then
|
Return Subst(("&1 KiB"), Format(Size / 1024, "0.##"))
|
||||||
Return Subst("&1 MiB", Format(Size / 1000000, "#.#"))
|
Else If Size < 1073741824 Then
|
||||||
|
Return Subst(("&1 MiB"), Format(Size / 1048576, "0.##"))
|
||||||
|
Else
|
||||||
|
Return Subst(("&1 GiB"), Format(Size / 1073741824, "0.##"))
|
||||||
|
Endif
|
||||||
Else
|
Else
|
||||||
Return Subst("&1 GiB", Format(Size / 1000000000, "#.#"))
|
If Size < 1000 Then
|
||||||
|
Return Subst(("&1 B"), CStr(Size))
|
||||||
|
Else If Size < 1000000 Then
|
||||||
|
Return Subst(("&1 KB"), Format(Size / 1000, "0.##"))
|
||||||
|
Else If Size < 1000000000 Then
|
||||||
|
Return Subst(("&1 MB"), Format(Size / 1000000, "0.##"))
|
||||||
|
Else
|
||||||
|
Return Subst(("&1 GB"), Format(Size / 1000000000, "0.##"))
|
||||||
|
Endif
|
||||||
Endif
|
Endif
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
Loading…
Reference in a new issue