Revert prior changes and fix #186

This commit is contained in:
Michael J. Seiferling
2019-04-27 12:44:27 -06:00
parent b48be71acc
commit 11db38108e
5 changed files with 12 additions and 88 deletions
+2 -2
View File
@@ -208,7 +208,7 @@ Public Class frmAddWizard
End Function
Private Function ValidateProcessPath(ByVal strPath As String, ByRef sErrorMessage As String) As Boolean
strPath = mgrPath.ValidatePathForOS(strPath)
strPath = mgrPath.ValidatePath(strPath)
If strPath.Trim = String.Empty Then
sErrorMessage = frmAddWizard_ErrorValidProcess
@@ -325,7 +325,7 @@ Public Class frmAddWizard
End If
Case eSteps.Step3
txtSavePath.Text = mgrPath.ValidatePathForOS(txtSavePath.Text)
txtSavePath.Text = mgrPath.ValidatePath(txtSavePath.Text)
If ValidateSavePath(txtSavePath.Text, sErrorMessage) Then
lblIncludePath.Text = txtSavePath.Text
lblExcludePath.Text = txtSavePath.Text
+3 -3
View File
@@ -574,7 +574,7 @@ Public Class frmGameManager
Private Function GetBuilderRoot() As String
Dim sRoot As String = String.Empty
Dim sPath As String = mgrPath.ValidatePathForOS(txtSavePath.Text)
Dim sPath As String = mgrPath.ValidatePath(txtSavePath.Text)
If Not Settings.ShowResolvedPaths Then sPath = mgrPath.ReplaceSpecialPaths(sPath)
@@ -1372,7 +1372,7 @@ Public Class frmGameManager
oApp.ProcessName = txtProcess.Text
oApp.Parameter = txtParameter.Text
oApp.OS = CType(cboOS.SelectedValue, clsGame.eOS)
oApp.Path = mgrPath.ValidatePathForOS(txtSavePath.Text)
oApp.Path = mgrPath.ValidatePath(txtSavePath.Text)
'If we have a registry path, trim any trailing backslashes because they cause export failures
If mgrPath.IsSupportedRegistryPath(oApp.Path) Then
@@ -1397,7 +1397,7 @@ Public Class frmGameManager
oApp.Comments = txtComments.Text
oApp.Enabled = chkEnabled.Checked
oApp.MonitorOnly = chkMonitorOnly.Checked
oApp.ProcessPath = mgrPath.ValidatePathForOS(txtAppPath.Text)
oApp.ProcessPath = mgrPath.ValidatePath(txtAppPath.Text)
oApp.Company = txtCompany.Text
oApp.Version = txtVersion.Text
oApp.Icon = txtIcon.Text
-56
View File
@@ -443,62 +443,6 @@ 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 prs As Process
Dim sOutput As String
Dim sDevice As String = String.Empty
Dim sDriveFormat As String = String.Empty
Try
prs = New Process
prs.StartInfo.FileName = "/bin/df"
prs.StartInfo.Arguments = "-T " & sPath
prs.StartInfo.UseShellExecute = False
prs.StartInfo.RedirectStandardOutput = True
prs.StartInfo.CreateNoWindow = True
prs.Start()
sOutput = prs.StandardOutput.ReadToEnd
sDevice = sOutput.Split(vbLf)(1).Split(New Char() {" "}, StringSplitOptions.RemoveEmptyEntries)(0)
sDriveFormat = sOutput.Split(vbLf)(1).Split(New Char() {" "}, StringSplitOptions.RemoveEmptyEntries)(1)
'If we are dealing with a fuseblk we have to figure out what the underlying file system is.
If sDriveFormat = "fuseblk" Then
prs = New Process
prs.StartInfo.FileName = "/bin/lsblk"
prs.StartInfo.Arguments = sDevice & " -no fstype"
prs.StartInfo.UseShellExecute = False
prs.StartInfo.RedirectStandardOutput = True
prs.StartInfo.CreateNoWindow = True
prs.Start()
sDriveFormat = prs.StandardOutput.ReadToEnd
End If
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
+7 -17
View File
@@ -101,8 +101,10 @@ Public Class mgrPath
End Set
End Property
Public Shared Function ValidatePathForOS(ByVal sCheckString As String) As String
Dim cInvalidCharacters As Char() = Path.GetInvalidPathChars
Public Shared Function ValidatePath(ByVal sCheckString As String) As String
Dim cInvalidCharacters As Char() = {Chr(0), Chr(1), Chr(2), Chr(3), Chr(4), Chr(5), Chr(6), Chr(7), Chr(8), Chr(9), Chr(10), Chr(11), Chr(12), Chr(13), Chr(14), Chr(15),
Chr(16), Chr(17), Chr(18), Chr(19), Chr(20), Chr(21), Chr(22), Chr(23), Chr(24), Chr(25), Chr(26), Chr(27), Chr(28), Chr(29), Chr(30),
Chr(31), Chr(34), Chr(60), Chr(62), Chr(124)}
For Each c As Char In cInvalidCharacters
sCheckString = sCheckString.Replace(c, "")
@@ -112,21 +114,9 @@ Public Class mgrPath
End Function
Public Shared Function ValidateFileName(ByVal sCheckString As String) As String
Dim sFormat As String
Dim oSettings As New mgrSettings
Dim cInvalidCharacters As Char()
oSettings.LoadSettings()
sFormat = oSettings.BackupDriveFormat.ToLower
If sFormat.StartsWith("fat") Or sFormat = "vfat" Or sFormat = "ntfs" Then
cInvalidCharacters = {"\", "/", ":", "*", "?", """", "<", ">", "|", Convert.ToChar(0)}
ElseIf sFormat.StartsWith("ext") Then
cInvalidCharacters = {"/", Convert.ToChar(0)}
Else
'When unable to determine the format, use the invalid characters provided by the OS.
cInvalidCharacters = Path.GetInvalidFileNameChars
End If
Dim cInvalidCharacters As Char() = {Chr(0), Chr(1), Chr(2), Chr(3), Chr(4), Chr(5), Chr(6), Chr(7), Chr(8), Chr(9), Chr(10), Chr(11), Chr(12), Chr(13), Chr(14), Chr(15),
Chr(16), Chr(17), Chr(18), Chr(19), Chr(20), Chr(21), Chr(22), Chr(23), Chr(24), Chr(25), Chr(26), Chr(27), Chr(28), Chr(29), Chr(30),
Chr(31), Chr(34), Chr(42), Chr(47), Chr(58), Chr(60), Chr(62), Chr(63), Chr(92), Chr(124)}
For Each c As Char In cInvalidCharacters
sCheckString = sCheckString.Replace(c, "")
-10
View File
@@ -255,16 +255,6 @@ Public Class mgrSettings
End Set
End Property
ReadOnly Property BackupDriveFormat As String
Get
If mgrCommon.IsUnix Then
Return mgrCommon.GetBackupDriveFormatUnix(sBackupFolder)
Else
Return mgrCommon.GetBackupDriveFormatWindows(sBackupFolder)
End If
End Get
End Property
Property SyncFields As clsGame.eOptionalSyncFields
Get
Return eSyncFields