Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Brown committed Dec 4, 2018
1 parent 903c357 commit 16c91b3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Unity/UnityDemo/Assets/AirSimAssets/Scripts/InitializeAirSim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,22 @@ public static string GetAirSimSettingsFileName()
}

fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), Path.Combine("AirSim", "settings.json"));
string linuxFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), Path.Combine("Documents/AirSim", "settings.json"));
Debug.Log(fileName);
Debug.Log(linuxFileName);
if (File.Exists(fileName))
{

return fileName;
}

else if (File.Exists(linuxFileName))
{
return linuxFileName;
}
if (CreateSettingsFileWithDefaultValues(fileName))
return fileName;
else if (CreateSettingsFileWithDefaultValues(linuxFileName))
return linuxFileName;
else
return string.Empty;
}
Expand All @@ -68,6 +75,11 @@ public static bool CreateSettingsFileWithDefaultValues(string fileName)
var result = false;
try
{
if (fileName.Substring(0, 5) == "/home")
Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Documents/AirSim"));
else
Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "AirSim"));

string content = "{\n \"SimMode\" : \"\", \n \"SettingsVersion\" : 1.2, \n \"SeeDocsAt\" : \"https://github.com/Microsoft/AirSim/blob/master/docs/settings.md\"\n}";
//settings file created at Documents\AirSim with name "setting.json".
StreamWriter writer = new StreamWriter(File.Open(fileName, FileMode.OpenOrCreate, FileAccess.Write));
Expand Down

0 comments on commit 16c91b3

Please sign in to comment.