All you need to do is paste the code into a 'Graphical Application' and run it. All it does is look at the drives and display the drive you click on in a DirChooser. There is a timer so that if you plug in (or remove) a USB drive /Mount (or unmount) a drive it should change the display. It will only display mounted drives.
I look forward to your comments.
' Gambas class file
sDriveToWorkWith As New String[]
HSplit1 As HSplit
DirChooser1 As DirChooser
GridViewDrives As GridView
LabelPath As Label
TimerGetData As Timer
siChange As Short
Public Sub Form_Open()
BuildForm
HSplit1.Layout = [70, 30]
TimerGetData_Timer
TimerGetData.Start
End
Public Sub GridViewDrives_Click()
Dim siRow, siCol As Short
DirChooser1.Root = GridViewDrives[Last.Row, 6].Text
For siRow = 0 To GridViewDrives.Rows.Max
For siCol = 0 To 6
If siRow <> Last.Row Then
GridViewDrives[siRow, siCol].Background = Color.Default
Else
GridViewDrives[siRow, siCol].Background = Color.LightGray
End If
Next
Next
End
Public Sub DisplayData()
Dim sHeader As String[] = ["Drive", "Type", "Size", "Used", "Available", "Used", "Mounted"]
Dim siRow, siCol As Short
With GridViewDrives
.Clear
.Columns.Count = 7
.Rows.Count = 0
End With
For siCol = 0 To 6
GridViewDrives.Columns[siCol].Title = sHeader[siCol]
Next
For siRow = 0 To sDriveToWorkWith.Max
Inc GridViewDrives.Rows.Count
For siCol = 0 To 6
GridViewDrives[siRow, siCol].Text = Split(sDriveToWorkWith[siRow], "`")[siCol]
Next
Next
GridViewDrives.Columns.Width = -1
GridViewDrives.Height = (GridViewDrives.Rows[0].Height * sDriveToWorkWith.Count) + 35
End
Public Sub TimerGetData_Timer()
Dim sData, sHold, sPart1, sPart2 As String
Dim sDrives As String[]
Dim siLoop, siSplit As Short
siChange = sDriveToWorkWith.Count
sDriveToWorkWith.Clear
Shell "df -aTh" To sData
sDrives = Split(sData, gb.NewLine, "", True)
For siLoop = 0 To sDrives.Max
If sDrives[siLoop] Begins "/dev/s" Then
sPart2 = Mid(sDrives[siLoop], InStr(sDrives[siLoop], "/", 6))
sPart1 = Mid(sDrives[siLoop], 1, InStr(sDrives[siLoop], "/", 6) - 1)
sData = ""
For siSplit = 0 To Split(sPart1, " ").Max
sData &= Split(sPart1, " ")[siSplit] & "`"
Next
Repeat
sHold = sData
sData = Replace(sData, "``", "`")
Until sData = sHold
If sData Ends "`" Then sData = Left(sData, -1)
sDriveToWorkWith.Add(sData & "`" & sPart2)
Endif
Next
If siChange <> sDriveToWorkWith.Count Then DisplayData
End
Public Sub DirChooser1_Change()
LabelPath.Text = DirChooser1.SelectedPath
End
Public Sub BuildForm()
With Me
.Height = 575
.Width = 1100
.Arrangement = Arrange.Vertical
.Padding = 5
End With
With HSplit1 = New HSplit(Me)
.Expand = True
.Layout = [70, 30]
End With
With GridViewDrives = New GridView(HSplit1) As "GridViewDrives"
.Header = GridView.Both
.Padding = 2
.AutoResize = True
End With
With DirChooser1 = New DirChooser(HSplit1) As "DirChooser1"
.Expand = True
End With
With LabelPath = New Label(Me) As "LabelPath"
.Alignment = Align.Right
.Font.Bold = True
.Height = 28
End With
With TimerGetData = New Timer As "TimerGetData"
.delay = 250
End With
End