diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb index 47bff44..c7445ef 100644 --- a/GBM/Forms/frmMain.vb +++ b/GBM/Forms/frmMain.vb @@ -1051,6 +1051,12 @@ Public Class frmMain Exit Sub End If + 'Check Special Paths + If Not mgrPath.CheckSpecialPaths Then + bInitFail = True + Exit Sub + End If + 'Local Database Check VerifyDBVersion(mgrSQLite.Database.Local) LocalDatabaseCheck() diff --git a/GBM/Managers/mgrPath.vb b/GBM/Managers/mgrPath.vb index f986be7..340ab22 100644 --- a/GBM/Managers/mgrPath.vb +++ b/GBM/Managers/mgrPath.vb @@ -202,6 +202,28 @@ Public Class mgrPath Return sResult End Function + Public Shared Function CheckSpecialPaths() As Boolean + Dim hshEnvs As New Hashtable + Dim bNoError As Boolean = True + + hshEnvs.Add("Documents", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)) + hshEnvs.Add("AppDataRoaming", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)) + hshEnvs.Add("AppDataLocal", Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)) + If Not mgrCommon.IsUnix Then + hshEnvs.Add("UserData", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)) + hshEnvs.Add("PublicDocuments", Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments)) + End If + + For Each de As DictionaryEntry In hshEnvs + If de.Value = String.Empty Then + mgrCommon.ShowMessage(mgrPath_SpecialPathError, de.Key, MsgBoxStyle.Critical) + bNoError = False + End If + Next + + Return bNoError + End Function + Public Shared Function ReplaceSpecialPaths(sValue As String) As String Dim sMyDocs As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) Dim sPublicDocs As String = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments) @@ -246,39 +268,45 @@ Public Class mgrPath Public Shared Function ReverseSpecialPaths(sValue As String) As String Dim sMyDocs As String = "*mydocs*" + Dim sEnvMyDocs As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) Dim sPublicDocs As String = "*publicdocs*" - Dim sAppDataRoaming As String = "*appdatalocal*" - Dim sAppDataLocal As String = "*appdataroaming*" + Dim sEnvPublicDocs As String = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments) + Dim sAppDataLocal As String = "*appdatalocal*" + Dim sEnvAppDataLocal As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + Dim sAppDataRoaming As String = "*appdataroaming*" + Dim sEnvAppDataRoaming As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) Dim sCurrentUser As String = "*currentuser*" + Dim sEnvCurrentUser As String = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) Dim oCustomVariable As clsPathVariable + For Each oCustomVariable In hshCustomVariables.Values If sValue.Contains(oCustomVariable.Path) Then Return sValue.Replace(oCustomVariable.Path, oCustomVariable.FormattedName) End If Next - If sValue.Contains(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)) Then - Return sValue.Replace(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), sAppDataLocal) + If sValue.Contains(sEnvAppDataRoaming) Then + Return sValue.Replace(sEnvAppDataRoaming, sAppDataRoaming) End If - If sValue.Contains(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)) Then - Return sValue.Replace(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), sAppDataRoaming) + If sValue.Contains(sEnvAppDataLocal) Then + Return sValue.Replace(sEnvAppDataLocal, sAppDataLocal) End If 'This needs to be tested last for Unix compatability - If sValue.Contains(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)) Then - Return sValue.Replace(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), sMyDocs) + If sValue.Contains(sEnvMyDocs) Then + Return sValue.Replace(sEnvMyDocs, sMyDocs) End If 'Don't use these in Unix If Not mgrCommon.IsUnix Then - If sValue.Contains(Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments)) Then - Return sValue.Replace(Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments), sPublicDocs) + If sValue.Contains(sEnvPublicDocs) Then + Return sValue.Replace(sEnvPublicDocs, sPublicDocs) End If - If sValue.Contains(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)) Then - Return sValue.Replace(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), sCurrentUser) + If sValue.Contains(sEnvCurrentUser) Then + Return sValue.Replace(sEnvCurrentUser, sCurrentUser) End If End If diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index 990aa6d..842f959 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -6060,6 +6060,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to An error occured while determining a required system path. [BR][BR]The environment value for [PARAM] is empty.[BR][BR]The application will now exit.. + ''' + Friend ReadOnly Property mgrPath_SpecialPathError() As String + Get + Return ResourceManager.GetString("mgrPath_SpecialPathError", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to [PARAM] backup restored.. ''' diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index b690293..02af0c3 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -2191,4 +2191,7 @@ A file with the same name already exists in the backup folder.[BR][BR]This game stores saves in a relative location, you may need to restore the current backup if the game was recently re-installed.[BR][BR]Do you want to overwrite this file? + + An error occured while determining a required system path. [BR][BR]The environment value for [PARAM] is empty.[BR][BR]The application will now exit. + \ No newline at end of file