Skip to content

Commit

Permalink
Remove df command to get Used space on partition
Browse files Browse the repository at this point in the history
  • Loading branch information
eloaders committed Jul 31, 2014
1 parent 1f007a9 commit 86767d7
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 22 deletions.
52 changes: 38 additions & 14 deletions I-Nex/i-nex/.src/Disk_Drives.module
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,25 @@ Public Sub get_informations()
Try rotational = Replace(File.Load("/sys/block/" & Finfosys.ComboBox4.Text & "/queue/rotational"), "\n", "")
Try rq_affinity = Replace(File.Load("/sys/block/" & Finfosys.ComboBox4.Text & "/queue/rq_affinity"), "\n", "")

Try partition_size = CalculateSIZE(CLong(Replace(File.Load("/sys/block/" & Finfosys.ComboBox4.Text & "/" & Finfosys.ComboBox3.Text & "/size"), "\n", "")))
Try real_size = CalculateSIZE(CLong(Replace(File.Load("/sys/block/" & Finfosys.ComboBox4.Text & "/size"), "\n", "")))
Try partition_size = CalculateSIZE(CLong(Replace(File.Load("/sys/block/" & Finfosys.ComboBox4.Text & "/" & Finfosys.ComboBox3.Text & "/size"), "\n", "")), True)
Try real_size = CalculateSIZE(CLong(Replace(File.Load("/sys/block/" & Finfosys.ComboBox4.Text & "/size"), "\n", "")), True)
Try max_ratio = Replace(File.Load("/sys/block/" & Finfosys.ComboBox4.Text & "/bdi/max_ratio"), "\n", "")
Try min_ratio = Replace(File.Load("/sys/block/" & Finfosys.ComboBox4.Text & "/bdi/min_ratio"), "\n", "")
Try stable_pages_required = Replace(File.Load("/sys/block/" & Finfosys.ComboBox4.Text & "/bdi/stable_pages_required"), "\n", "")

Shell "LC_ALL=C df | grep \"" & Finfosys.ComboBox3.Text & "\" | awk {'print $5'} | sed -n '1p'" Wait To used
Used = Replace(Replace(Used, "%", ""), "\n", "")
Logs("Get informations of Drives Done", Logger.Info)
disks()
mount_point = Replace(mount_point, "\\040", " ")
Try FREE_SPACE = CalculateFreeSpace(Dfree(mount_point))
Try FREE_SPACE = CalculateFreeSpace(Dfree(mount_point), True)
Finfosys.Label248.Text = "Free: " & FREE_SPACE
Finfosys.ProgressBar2.Value = 0
Used = Null
Try Used = (Val(CalculateSIZE(CLong(Replace(File.Load("/sys/block/" & Finfosys.ComboBox4.Text & "/" & Finfosys.ComboBox3.Text & "/size"), "\n", "")))) - Val(CalculateFreeSpace(Dfree(mount_point))))
Try Finfosys.ProgressBar2.Value = Val(Used) / Val(CalculateSIZE(CLong(Replace(File.Load("/sys/block/" & Finfosys.ComboBox4.Text & "/" & Finfosys.ComboBox3.Text & "/size"), "\n", ""))))

End

Function CalculateFreeSpace(Size As Float) As String
Function CalculateFreeSpace(Size As Float, Optional ReturnIn As Boolean) As String
Dim REAL_SIZE_KIB As Float
Dim REAL_SIZE_MB As Float
Dim REAL_SIZE_GB As Float
Expand All @@ -146,22 +149,31 @@ Function CalculateFreeSpace(Size As Float) As String
If CLong(REAL_SIZE_GB) > 0 Then

iPos = InStr(CString(REAL_SIZE_GB), ".")
If ReturnIn = True Then
Return Left$(CString(REAL_SIZE_GB), iPos + 1) & " GB"

Else
Return Left$(CString(REAL_SIZE_GB), iPos + 1)
Endif
Else If CLong(REAL_SIZE_MB) > 0 Then
iPos = InStr(CString(REAL_SIZE_MB), ".")
If ReturnIn = True Then
Return Left$(CString(REAL_SIZE_MB), iPos + 1) & " MB"

Else
Return Left$(CString(REAL_SIZE_MB), iPos + 1)
Endif
Else If CLong(REAL_SIZE_KIB) > 0 Then
iPos = InStr(CString(REAL_SIZE_KIB), ".")
If ReturnIn = True Then
Return Left$(CString(REAL_SIZE_KIB), iPos + 1) & " KiB"

Else
Return Left$(CString(REAL_SIZE_KIB), iPos + 1)
Endif
Endif
Dec iPos
End


Function CalculateSIZE(BlockSize As Float) As String
Function CalculateSIZE(BlockSize As Float, Optional ReturnIn As Boolean) As String
Dim REAL_SIZE_BYTES As Float
Dim REAL_SIZE_KIB As Float
Dim REAL_SIZE_MB As Float
Expand All @@ -177,20 +189,32 @@ Function CalculateSIZE(BlockSize As Float) As String
If CLong(REAL_SIZE_GB) > 0 Then

iPos = InStr(CString(REAL_SIZE_GB), ".")
If ReturnIn = True Then
Return Left$(CString(REAL_SIZE_GB), iPos + 1) & " GB"

Else
Return Left$(CString(REAL_SIZE_GB), iPos + 1)
Endif
Else If CLong(REAL_SIZE_MB) > 0 Then
iPos = InStr(CString(REAL_SIZE_MB), ".")
If ReturnIn = True Then
Return Left$(CString(REAL_SIZE_MB), iPos + 1) & " MB"

Else
Return Left$(CString(REAL_SIZE_MB), iPos + 1)
Endif
Else If CLong(REAL_SIZE_KIB) > 0 Then
iPos = InStr(CString(REAL_SIZE_KIB), ".")
If ReturnIn = True Then
Return Left$(CString(REAL_SIZE_KIB), iPos + 1) & " KiB"

Else
Return Left$(CString(REAL_SIZE_KIB), iPos + 1)
Endif
Else If CLong(REAL_SIZE_BYTES) > 0 Then
iPos = InStr(CString(REAL_SIZE_BYTES), ".")
If ReturnIn = True Then
Return Left$(CString(REAL_SIZE_BYTES), iPos + 1) & " Bytes"

Else
Return Left$(CString(REAL_SIZE_BYTES), iPos + 1)
Endif
Endif
Dec iPos
End
Expand Down
16 changes: 8 additions & 8 deletions I-Nex/i-nex/.src/Finfosys.class
Original file line number Diff line number Diff line change
Expand Up @@ -860,14 +860,14 @@ Label134.Text = "Rq affinity: " & Disk_Drives.rq_affinity & "" ' rq_affinity
If Disk_Drives.removable Like "1" Then
Label45.Text = "Removable: Yes"
Endif
If Disk_Drives.Used <> 0 Then
Try ProgressBar2.Value = Disk_Drives.Used / 100
ProgressBar2.ToolTip = Disk_Drives.Used & "%"
Endif
If Disk_Drives.Used = Null Then
ProgressBar2.Value = 0
ProgressBar2.ToolTip = "Unknown"
Endif
' If Disk_Drives.Used <> 0 Then
' Try ProgressBar2.Value = Disk_Drives.Used / 100
' ProgressBar2.ToolTip = Disk_Drives.Used & "%"
' Endif
' If Disk_Drives.Used = Null Then
' ProgressBar2.Value = 0
' ProgressBar2.ToolTip = "Unknown"
' Endif
If IsNull(ComboBox3.Text) = False Then
If Disk_Drives.check_swap Like "*" & ComboBox3.Text & "*" Then
Label48.Visible = True
Expand Down

0 comments on commit 86767d7

Please sign in to comment.