Changes for #186
This commit is contained in:
@@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
ReadOnly Property FileSafeName As String
|
ReadOnly Property FileSafeName As String
|
||||||
Get
|
Get
|
||||||
Return mgrPath.ValidateFileNameForOS(sName)
|
Return mgrPath.ValidateFileName(sName)
|
||||||
End Get
|
End Get
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ Public Class clsGame
|
|||||||
Property ID As String
|
Property ID As String
|
||||||
Set(value As String)
|
Set(value As String)
|
||||||
If Not value Is Nothing Then
|
If Not value Is Nothing Then
|
||||||
sGameID = mgrPath.ValidateFileNameForOS(value)
|
sGameID = mgrPath.ValidateFileName(value)
|
||||||
End If
|
End If
|
||||||
End Set
|
End Set
|
||||||
Get
|
Get
|
||||||
@@ -70,7 +70,7 @@ Public Class clsGame
|
|||||||
|
|
||||||
ReadOnly Property FileSafeName As String
|
ReadOnly Property FileSafeName As String
|
||||||
Get
|
Get
|
||||||
Return mgrPath.ValidateFileNameForOS(sGameName)
|
Return mgrPath.ValidateFileName(sGameName)
|
||||||
End Get
|
End Get
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
|
|||||||
@@ -1361,7 +1361,7 @@ Public Class frmGameManager
|
|||||||
oApp.IsRegEx = chkRegEx.Checked
|
oApp.IsRegEx = chkRegEx.Checked
|
||||||
|
|
||||||
If Not oApp.IsRegEx Then
|
If Not oApp.IsRegEx Then
|
||||||
txtProcess.Text = mgrPath.ValidateFileNameForOS(txtProcess.Text)
|
txtProcess.Text = mgrPath.ValidateFileName(txtProcess.Text)
|
||||||
If Path.HasExtension(txtProcess.Text) Then
|
If Path.HasExtension(txtProcess.Text) Then
|
||||||
If txtProcess.Text.ToLower.EndsWith(".exe") Then
|
If txtProcess.Text.ToLower.EndsWith(".exe") Then
|
||||||
txtProcess.Text = Path.GetFileNameWithoutExtension(txtProcess.Text)
|
txtProcess.Text = Path.GetFileNameWithoutExtension(txtProcess.Text)
|
||||||
|
|||||||
+25
-10
@@ -445,21 +445,36 @@ Public Class mgrCommon
|
|||||||
|
|
||||||
'Get the drive format of a location (Unix)
|
'Get the drive format of a location (Unix)
|
||||||
Public Shared Function GetBackupDriveFormatUnix(ByVal sPath As String) As String
|
Public Shared Function GetBackupDriveFormatUnix(ByVal sPath As String) As String
|
||||||
Dim prsdf As Process
|
Dim prs As Process
|
||||||
Dim sOutput As String
|
Dim sOutput As String
|
||||||
|
Dim sDevice As String = String.Empty
|
||||||
Dim sDriveFormat As String = String.Empty
|
Dim sDriveFormat As String = String.Empty
|
||||||
|
|
||||||
Try
|
Try
|
||||||
prsdf = New Process
|
prs = New Process
|
||||||
prsdf.StartInfo.FileName = "/bin/df"
|
prs.StartInfo.FileName = "/bin/df"
|
||||||
prsdf.StartInfo.Arguments = "-T " & sPath
|
prs.StartInfo.Arguments = "-T " & sPath
|
||||||
prsdf.StartInfo.UseShellExecute = False
|
prs.StartInfo.UseShellExecute = False
|
||||||
prsdf.StartInfo.RedirectStandardOutput = True
|
prs.StartInfo.RedirectStandardOutput = True
|
||||||
prsdf.StartInfo.CreateNoWindow = True
|
prs.StartInfo.CreateNoWindow = True
|
||||||
prsdf.Start()
|
prs.Start()
|
||||||
sOutput = prsdf.StandardOutput.ReadToEnd
|
|
||||||
'Parse df output to grab "Type" value
|
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)
|
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
|
Catch
|
||||||
'Do Nothing
|
'Do Nothing
|
||||||
End Try
|
End Try
|
||||||
|
|||||||
+18
-4
@@ -111,15 +111,29 @@ Public Class mgrPath
|
|||||||
Return sCheckString.Trim
|
Return sCheckString.Trim
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Shared Function ValidateFileNameForOS(ByVal sCheckString As String) As String
|
Public Shared Function ValidateFileName(ByVal sCheckString As String) As String
|
||||||
Dim cInvalidCharacters As Char() = Path.GetInvalidFileNameChars
|
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
|
For Each c As Char In cInvalidCharacters
|
||||||
sCheckString = sCheckString.Replace(c, "")
|
sCheckString = sCheckString.Replace(c, "")
|
||||||
Next
|
Next
|
||||||
|
|
||||||
If sCheckString.Length > 257 Then
|
If sCheckString.Length > 255 Then
|
||||||
sCheckString = sCheckString.Substring(0, 257)
|
sCheckString = sCheckString.Substring(0, 255)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Return sCheckString.Trim
|
Return sCheckString.Trim
|
||||||
|
|||||||
Reference in New Issue
Block a user