Skip to content

Commit

Permalink
Fix issue for OSX users.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rychard committed Mar 29, 2015
1 parent 60a4506 commit b23a408
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion CityWebServer/Helpers/ConfigurationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Globalization;
using System.IO;
using System.Linq;
using ColossalFramework.IO;
using JsonFx.Serialization;

namespace CityWebServer.Helpers
Expand All @@ -25,7 +26,30 @@ public static String GetSettingsFilePath()
var vendorRoot = System.IO.Path.Combine(localApplicationDataRoot, "Colossal Order");
var appRoot = System.IO.Path.Combine(vendorRoot, "Cities_Skylines");
var filePath = System.IO.Path.Combine(appRoot, "ModSettings.json");
return filePath;

// This works for Windows, but not for OSX.
if (CanAccess(filePath))
{
return filePath;
}

// If we just use a filename, it will exist in the root directory of the game's files. Not ideal, but it'll work.
return "ModSettings.json";
}

private static Boolean CanAccess(String filePath)
{
try
{
using (var fileStream = System.IO.File.Open(filePath, FileMode.OpenOrCreate, FileAccess.Read))
{
return true;
}
}
catch (Exception)
{
return false;
}
}

private static void LoadSettings()
Expand Down

0 comments on commit b23a408

Please # to comment.