~sebikul/mundus/mundus-git

« back to all changes in this revision

Viewing changes to .src/Main.module

  • Committer: Sebi
  • Date: 2015-12-01 23:14:32 UTC
  • Revision ID: git-v1:bc907761723b955cad8a13c3c3cafd4cfe78dcb7
Tags: v3.0.1
Fixed path parsing and a spacing issue in the Backups form

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
Public Sub Main()
34
34
 
35
 
  If Not CheckProgram("du") Then
 
35
  If Not PathHelper.CheckProgram("du") Then
36
36
    Message.Title = ("coreutils not found")
37
37
    Message.Error(("You need to install coreutils"))
38
38
    Return
73
73
 
74
74
End
75
75
 
76
 
Public Function CheckProgram(sProg As String) As Boolean
77
 
 
78
 
  Dim iPos As Integer
79
 
 
80
 
  iPos = InStr(sProg, " ")
81
 
  If iPos Then sProg = Left(sProg, iPos - 1)
82
 
 
83
 
  Shell "which " & sProg & " >/dev/null 2>&1" Wait
84
 
 
85
 
  Return (Process.LastValue = 0)
86
 
 
87
 
End
88
 
 
89
 
Public Function GetDirectorySize(Path As String) As Long
90
 
 
91
 
  Dim sSize As String
92
 
 
93
 
  If Not Exist(Path) Then Return 0
94
 
 
95
 
  Shell "du -bs " & Shell(Path) To sSize
96
 
 
97
 
  Return CLong(Split(sSize, "\t")[0])
98
 
 
99
 
End
100
 
 
101
76
Public Function Trim(Name As String) As String
102
77
 
103
78
  Return Replace(Name, " ", "_")
110
85
 
111
86
End
112
87
 
113
 
Public Function SetSizeLabelScale(Size As Long) As String
114
 
 
115
 
  Dim RetVal As Float
116
 
 
117
 
  Dim sPower As String
118
 
 
119
 
  Dim KB As Integer = 1024
120
 
  Dim MB As Integer = KB * KB
121
 
  Dim GB As Integer = MB * KB
122
 
 
123
 
  If Size >= 0 And Size < KB Then
124
 
 
125
 
    sPower = "B"
126
 
    RetVal = Size
127
 
 
128
 
  Else If Size >= KB And Size < MB Then
129
 
 
130
 
    sPower = "KB"
131
 
    RetVal = Round(Size / KB, -2)
132
 
 
133
 
  Else If Size >= MB And Size < GB Then
134
 
 
135
 
    sPower = "MB"
136
 
    RetVal = Round(Size / MB, -2)
137
 
 
138
 
  Else If Size >= GB Then
139
 
 
140
 
    sPower = "GB"
141
 
    RetVal = Round(Size / GB, -2)
142
 
 
143
 
  Else
144
 
 
145
 
    sPower = "B"
146
 
    RetVal = Size
147
 
 
148
 
  Endif
149
 
 
150
 
  Return Subst("&1 &2", RetVal, sPower)
151
 
 
152
 
End
153
 
 
154
88
Private Function PATH_MAIN_Read() As String
155
89
 
156
90
  Return _CheckAndCreate(User.Home &/ ".mundus")