Changes for issue #123 (Pass 1)

This commit is contained in:
MikeMaximus
2018-02-18 09:38:52 -06:00
parent e897fda8e8
commit 1c54085d6c
8 changed files with 35 additions and 26 deletions
+6
View File
@@ -27,6 +27,12 @@
End Set
End Property
ReadOnly Property SafeName As String
Get
Return mgrPath.ValidateForFileSystem(sName)
End Get
End Property
ReadOnly Property CroppedName As String
Get
If Name.Length > 40 Then
+7 -1
View File
@@ -46,7 +46,7 @@ Public Class clsGame
ReadOnly Property CompoundKey As String
Get
Return ProcessName & ":" & Name
Return ProcessName & ":" & SafeName
End Get
End Property
@@ -69,6 +69,12 @@ Public Class clsGame
End Get
End Property
ReadOnly Property SafeName As String
Get
Return mgrPath.ValidateForFileSystem(sGameName)
End Get
End Property
Property ProcessName As String
Set(value As String)
sProcessName = value
+5 -8
View File
@@ -195,10 +195,7 @@ Public Class frmAddWizard
End Sub
Private Function ValidateName(ByVal strName As String, ByRef sErrorMessage As String) As Boolean
If txtName.Text <> String.Empty Then
txtName.Text = mgrPath.ValidateForFileSystem(txtName.Text)
Return True
Else
If txtName.Text.Trim = String.Empty Then
sErrorMessage = frmAddWizard_ErrorValidName
txtName.Focus()
Return False
@@ -207,7 +204,7 @@ Public Class frmAddWizard
End Function
Private Function ValidateProcessPath(ByVal strPath As String, ByRef sErrorMessage As String) As Boolean
If strPath = String.Empty Then
If strPath.Trim = String.Empty Then
sErrorMessage = frmAddWizard_ErrorValidProcess
txtProcessPath.Focus()
Return False
@@ -235,7 +232,7 @@ Public Class frmAddWizard
End Function
Private Function ValidateSavePath(ByVal strPath As String, ByRef sErrorMessage As String) As Boolean
If strPath = String.Empty Then
If strPath.Trim = String.Empty Then
sErrorMessage = frmAddWizard_ErrorValidSavePath
txtSavePath.Focus()
Return False
@@ -257,7 +254,7 @@ Public Class frmAddWizard
End Function
Private Function ValidateSaveType(ByVal strSaveType As String, ByRef sErrorMessage As String)
If strSaveType = String.Empty Then
If strSaveType.Trim = String.Empty Then
sErrorMessage = frmAddWizard_ErrorValidSaveType
txtFileTypes.Focus()
Return False
@@ -268,7 +265,7 @@ Public Class frmAddWizard
Private Sub DoSave()
Dim hshDupeCheck As New Hashtable
Dim sNewGame As String = oGameToSave.ProcessName & ":" & oGameToSave.Name
Dim sNewGame As String = oGameToSave.ProcessName & ":" & oGameToSave.SafeName
For Each o As clsGame In GameData.Values
hshDupeCheck.Add(o.CompoundKey, String.Empty)
+7 -7
View File
@@ -183,14 +183,14 @@ Public Class frmGameManager
sFileName = BackupFolder & oBackupItem.FileName
'Rename Backup File
sNewFileName = Path.GetDirectoryName(sFileName) & Path.DirectorySeparatorChar & Path.GetFileName(sFileName).Replace(oOriginalApp.Name, oNewApp.Name)
sNewFileName = Path.GetDirectoryName(sFileName) & Path.DirectorySeparatorChar & Path.GetFileName(sFileName).Replace(oOriginalApp.SafeName, oNewApp.SafeName)
If File.Exists(sFileName) Then
FileSystem.Rename(sFileName, sNewFileName)
End If
'Rename Directory
sDirectory = Path.GetDirectoryName(sFileName)
sNewDirectory = sDirectory.Replace(oOriginalApp.Name, oNewApp.Name)
sNewDirectory = sDirectory.Replace(oOriginalApp.SafeName, oNewApp.SafeName)
If sDirectory <> sNewDirectory Then
If Directory.Exists(sDirectory) Then
FileSystem.Rename(sDirectory, sNewDirectory)
@@ -198,7 +198,7 @@ Public Class frmGameManager
End If
oBackupItem.Name = oNewApp.Name
oBackupItem.FileName = oBackupItem.FileName.Replace(oOriginalApp.Name, oNewApp.Name)
oBackupItem.FileName = oBackupItem.FileName.Replace(oOriginalApp.SafeName, oNewApp.SafeName)
mgrManifest.DoManifestUpdateByID(oBackupItem, mgrSQLite.Database.Local)
Next
oLocalBackupData = mgrManifest.ReadLatestManifest(mgrSQLite.Database.Local)
@@ -210,7 +210,7 @@ Public Class frmGameManager
For Each oBackupItem As clsBackup In oBackupItems
oBackupItem.Name = oNewApp.Name
oBackupItem.FileName = oBackupItem.FileName.Replace(oOriginalApp.Name, oNewApp.Name)
oBackupItem.FileName = oBackupItem.FileName.Replace(oOriginalApp.SafeName, oNewApp.SafeName)
mgrManifest.DoManifestUpdateByID(oBackupItem, mgrSQLite.Database.Remote)
Next
oRemoteBackupData = mgrManifest.ReadLatestManifest(mgrSQLite.Database.Remote)
@@ -1160,7 +1160,7 @@ Public Class frmGameManager
If txtID.Text <> String.Empty Then
oApp.ID = txtID.Text
End If
oApp.Name = mgrPath.ValidateForFileSystem(txtName.Text)
oApp.Name = txtName.Text
If Path.HasExtension(txtProcess.Text) Then
If txtProcess.Text.ToLower.EndsWith(".exe") Then
oApp.ProcessName = Path.GetFileNameWithoutExtension(txtProcess.Text)
@@ -1280,13 +1280,13 @@ Public Class frmGameManager
End Sub
Private Function CoreValidatation(ByVal oApp As clsGame) As Boolean
If txtName.Text = String.Empty Then
If txtName.Text.Trim = String.Empty Then
mgrCommon.ShowMessage(frmGameManager_ErrorValidName, MsgBoxStyle.Exclamation)
txtName.Focus()
Return False
End If
If txtProcess.Text = String.Empty Then
If txtProcess.Text.Trim = String.Empty Then
mgrCommon.ShowMessage(frmGameManager_ErrorValidProcess, MsgBoxStyle.Exclamation)
txtProcess.Focus()
Return False
+5 -5
View File
@@ -107,8 +107,8 @@ Public Class mgrBackup
Dim lAvailableSpace As Long
Dim lFolderSize As Long
If oSettings.CreateSubFolder Then sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.Name
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.Name & ".7z"
If oSettings.CreateSubFolder Then sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.SafeName
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.SafeName & ".7z"
'Verify saved game path
sSavePath = VerifySavePath(oGame)
@@ -199,7 +199,7 @@ Public Class mgrBackup
RaiseEvent UpdateBackupInfo(oGame)
If oSettings.CreateSubFolder Then
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.Name
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.SafeName
Try
If Not Directory.Exists(sBackupFile) Then
Directory.CreateDirectory(sBackupFile)
@@ -212,9 +212,9 @@ Public Class mgrBackup
If oGame.AppendTimeStamp Then
CheckOldBackups(oGame)
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.Name & sTimeStamp & ".7z"
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.SafeName & sTimeStamp & ".7z"
Else
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.Name & ".7z"
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.SafeName & ".7z"
End If
If bDoBackup Then
+2 -2
View File
@@ -430,10 +430,10 @@ Public Class mgrCommon
'Delete a sub-folder based on the provided backup information
Public Shared Sub DeleteDirectoryByBackup(ByVal sBackupFolder As String, ByVal oBackup As clsBackup)
Dim oDir As DirectoryInfo
Dim sDir As String = sBackupFolder & oBackup.Name
Dim sDir As String = sBackupFolder & oBackup.SafeName
'Delete sub directory if it's empty
If oBackup.FileName.StartsWith(oBackup.Name & Path.DirectorySeparatorChar) Then
If oBackup.FileName.StartsWith(oBackup.SafeName & Path.DirectorySeparatorChar) Then
If Directory.Exists(sDir) Then
'Check if there's any sub-directories or files remaining
oDir = New DirectoryInfo(sDir)
+2 -2
View File
@@ -85,13 +85,13 @@ Public Class mgrMonitorList
Select Case eListType
Case eListTypes.FullList
'Don't wrap this, if it fails there's a problem with the database
hshList.Add(oGame.ProcessName & ":" & oGame.Name, oGame)
hshList.Add(oGame.ProcessName & ":" & oGame.SafeName, oGame)
Case eListTypes.ScanList
For Each de As DictionaryEntry In hshList
oCompareGame = DirectCast(de.Value, clsGame)
If Regex.IsMatch(oGame.ProcessName, oCompareGame.ProcessName) Or (oGame.ProcessName = oCompareGame.ProcessName) Then
DirectCast(hshList.Item(oCompareGame.ProcessName), clsGame).Duplicate = True
oGame.ProcessName = oGame.ProcessName & ":" & oGame.Name
oGame.ProcessName = oGame.ProcessName & ":" & oGame.SafeName
oGame.Duplicate = True
End If
Next
+1 -1
View File
@@ -42,7 +42,7 @@ Public Class mgrXML
'This should be wrapped just in case we get some bad data
Try
hshList.Add(oGame.ProcessName & ":" & oGame.Name, oGame)
hshList.Add(oGame.ProcessName & ":" & oGame.SafeName, oGame)
Catch e As Exception
'Do Nothing
End Try