Skip to content

Commit

Permalink
Better handling of backup of old directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandrem committed Feb 13, 2021
1 parent 391751e commit ade3fd0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Assets/Scripts/Model/SquadBuilder/RandomSquads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ public static void SetRandomAiSquad()
private static JSONObject GetRandomAiSquad()
{
string oldDirectoryPath = Application.persistentDataPath + "/" + Edition.Current.Name + "/RandomAiSquadrons";
if (Directory.Exists(oldDirectoryPath)) Directory.Move(oldDirectoryPath, oldDirectoryPath + "-IsNotUsedAnymore");
try
{
if (Directory.Exists(oldDirectoryPath)) Directory.Move(oldDirectoryPath, oldDirectoryPath + "-IsNotUsedAnymore");
}
catch
{
Messages.ShowError("Backup of old directory is failed: " + oldDirectoryPath);
}

string directoryPathPrefix = Application.persistentDataPath + "/" + Edition.Current.Name + "/AiSquadrons";
if (!Directory.Exists(directoryPathPrefix)) Directory.CreateDirectory(directoryPathPrefix);
Expand Down

0 comments on commit ade3fd0

Please sign in to comment.