Updated backup drive format property to handle Linux

This commit is contained in:
Michael J. Seiferling
2019-04-27 09:21:45 -06:00
parent 9b45ae7b1c
commit f77a900f56
2 changed files with 46 additions and 11 deletions
+41
View File
@@ -443,6 +443,47 @@ Public Class mgrCommon
Return lSize
End Function
'Get the drive format of a location (Unix)
Public Shared Function GetBackupDriveFormatUnix(ByVal sPath As String) As String
Dim prsdf As Process
Dim sOutput As String
Dim sDriveFormat As String = String.Empty
Try
prsdf = New Process
prsdf.StartInfo.FileName = "/bin/df"
prsdf.StartInfo.Arguments = "-T " & sPath
prsdf.StartInfo.UseShellExecute = False
prsdf.StartInfo.RedirectStandardOutput = True
prsdf.StartInfo.CreateNoWindow = True
prsdf.Start()
sOutput = prsdf.StandardOutput.ReadToEnd
'Parse df output to grab "Type" value
sDriveFormat = sOutput.Split(vbLf)(1).Split(New Char() {" "}, StringSplitOptions.RemoveEmptyEntries)(1)
Catch
'Do Nothing
End Try
Return sDriveFormat
End Function
'Get the drive format of a location (Windows)
Public Shared Function GetBackupDriveFormatWindows(ByVal sPath As String) As String
Dim oBackupDrive As DriveInfo
Dim sFormat As String = String.Empty
Try
If Directory.Exists(sPath) Then
oBackupDrive = New DriveInfo(Path.GetPathRoot(sPath))
sFormat = oBackupDrive.DriveFormat
End If
Catch
'Do Nothing
End Try
Return sFormat
End Function
'Get available disk space on a drive (Unix)
Private Shared Function GetAvailableDiskSpaceUnix(ByVal sPath As String) As Long
Dim prsdf As Process
+5 -11
View File
@@ -257,17 +257,11 @@ Public Class mgrSettings
ReadOnly Property BackupDriveFormat As String
Get
Dim oBackupDrive As DriveInfo
Dim sFormat As String = String.Empty
Try
If Directory.Exists(sBackupFolder) Then
oBackupDrive = New DriveInfo(Path.GetPathRoot(sBackupFolder))
sFormat = oBackupDrive.DriveFormat
End If
Catch
'Do Nothing
End Try
Return sFormat
If mgrCommon.IsUnix Then
Return mgrCommon.GetBackupDriveFormatUnix(sBackupFolder)
Else
Return mgrCommon.GetBackupDriveFormatWindows(sBackupFolder)
End If
End Get
End Property