Changes for #186

This commit is contained in:
Michael J. Seiferling
2019-04-27 10:31:09 -06:00
parent f77a900f56
commit aa37c6525d
5 changed files with 47 additions and 18 deletions
+1 -1
View File
@@ -49,7 +49,7 @@
ReadOnly Property FileSafeName As String
Get
Return mgrPath.ValidateFileNameForOS(sName)
Return mgrPath.ValidateFileName(sName)
End Get
End Property
+2 -2
View File
@@ -50,7 +50,7 @@ Public Class clsGame
Property ID As String
Set(value As String)
If Not value Is Nothing Then
sGameID = mgrPath.ValidateFileNameForOS(value)
sGameID = mgrPath.ValidateFileName(value)
End If
End Set
Get
@@ -70,7 +70,7 @@ Public Class clsGame
ReadOnly Property FileSafeName As String
Get
Return mgrPath.ValidateFileNameForOS(sGameName)
Return mgrPath.ValidateFileName(sGameName)
End Get
End Property
+1 -1
View File
@@ -1361,7 +1361,7 @@ Public Class frmGameManager
oApp.IsRegEx = chkRegEx.Checked
If Not oApp.IsRegEx Then
txtProcess.Text = mgrPath.ValidateFileNameForOS(txtProcess.Text)
txtProcess.Text = mgrPath.ValidateFileName(txtProcess.Text)
If Path.HasExtension(txtProcess.Text) Then
If txtProcess.Text.ToLower.EndsWith(".exe") Then
txtProcess.Text = Path.GetFileNameWithoutExtension(txtProcess.Text)
+25 -10
View File
@@ -445,21 +445,36 @@ Public Class mgrCommon
'Get the drive format of a location (Unix)
Public Shared Function GetBackupDriveFormatUnix(ByVal sPath As String) As String
Dim prsdf As Process
Dim prs As Process
Dim sOutput As String
Dim sDevice As String = String.Empty
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
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
+18 -4
View File
@@ -111,15 +111,29 @@ Public Class mgrPath
Return sCheckString.Trim
End Function
Public Shared Function ValidateFileNameForOS(ByVal sCheckString As String) As String
Dim cInvalidCharacters As Char() = Path.GetInvalidFileNameChars
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.Contains("fat") Or sFormat.Contains("ntfs") Then
cInvalidCharacters = {"\", "/", ":", "*", "?", """", "<", ">", "|", Convert.ToChar(0)}
ElseIf sFormat.Contains("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
For Each c As Char In cInvalidCharacters
sCheckString = sCheckString.Replace(c, "")
Next
If sCheckString.Length > 257 Then
sCheckString = sCheckString.Substring(0, 257)
If sCheckString.Length > 255 Then
sCheckString = sCheckString.Substring(0, 255)
End If
Return sCheckString.Trim