Skip to content

Commit

Permalink
Fixing BUG: Appdata directory is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
haseeb-heaven committed Aug 31, 2024
1 parent c8ba0e0 commit b2f5f80
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions QVMEditor/QUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,36 @@ private static void MoveQEditorDir(string destPath)
var qCompilerCurrPath = qEdCurrPath + "\\" + "QCompiler";
var keywordFilePath = qEdCurrPath + "\\" + keywordsFile;

if (Directory.Exists(qEdCurrPath) && Directory.Exists(qCompilerCurrPath) && !Directory.Exists(qvmEditorQEdPath))
try
{
DirectoryMove(qEdCurrPath, destPath + "\\" + "QEditor");
if (Directory.Exists(qEdCurrPath) && Directory.Exists(qCompilerCurrPath) && !Directory.Exists(qvmEditorQEdPath))
{
DirectoryMove(qEdCurrPath, destPath + "\\" + "QEditor");
}
if (File.Exists(keywordFilePath))
{
QUtils.FileIOMove(keywordFilePath, qvmEditorQEdPath + "\\" + keywordsFile);
}
}
if (File.Exists(keywordFilePath))
catch (Exception ex)
{
QUtils.FileIOMove(keywordFilePath, qvmEditorQEdPath + "\\" + keywordsFile);
try
{
if (Directory.Exists(qEdCurrPath) && Directory.Exists(qCompilerCurrPath) && !Directory.Exists(qvmEditorQEdPath))
{
DirectoryCopy(qEdCurrPath, destPath + "\\" + "QEditor", true);
Directory.Delete(qEdCurrPath, true);
}
if (File.Exists(keywordFilePath))
{
QUtils.FileIOMove(keywordFilePath, qvmEditorQEdPath + "\\" + keywordsFile);
}
}
catch (Exception innerEx)
{
ShowLogException(MethodBase.GetCurrentMethod().Name, innerEx);
throw;
}
}
}

Expand Down Expand Up @@ -122,6 +145,8 @@ internal static bool InitEditorAppData()
objectsModelsFile = qvmEditorQEdPath + Path.DirectorySeparatorChar + "IGIModels.json";
tempPathFile = qvmEditorQEdPath + "\\" + tempPathFileName;

MoveQEditorDir(appdataPath);

if (!Directory.Exists(qvmEditorQEdPath)) { initErrReason = "QEditor"; initStatus = false; }
else if (!Directory.Exists(qCompilerPath)) { initErrReason = @"QEditor\QCompiler"; initStatus = false; }

Expand All @@ -130,10 +155,9 @@ internal static bool InitEditorAppData()
//Show error if 'QEditor' path has invalid structure..
if (!initStatus)
{
ShowSystemFatalError("QVVM Editor Appdata directory is invalid Error: (0x0000000F)\nReason: " + initErrReason + "\nPlease re-install new copy from Setup file.");
ShowSystemFatalError("QVM Editor Appdata directory is invalid Error: (0x0000000F)\nReason: " + initErrReason + "\nPlease re-install new copy from Setup file.");
}

MoveQEditorDir(appdataPath);
//Init Game objects and Keywords.
InitGameObjectsInfo();
InitKeywords();
Expand Down

0 comments on commit b2f5f80

Please sign in to comment.