Skip to content

Commit

Permalink
Create setting directory when not found
Browse files Browse the repository at this point in the history
  • Loading branch information
kagikn committed Aug 17, 2017
1 parent dd5ba77 commit d3bf089
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 3 additions & 6 deletions StuntBonusV/Setting/SettingLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@ public bool Save(string xmlPath, T settings)
{
var serializer = new XmlSerializer(typeof(T));

if (File.Exists(xmlPath))
using (var stream = new FileStream(xmlPath, File.Exists(xmlPath) ? FileMode.Truncate : FileMode.Create, FileAccess.ReadWrite))
{
using (var stream = new FileStream(xmlPath, File.Exists(xmlPath) ? FileMode.Truncate : FileMode.Create, FileAccess.ReadWrite))
{
serializer.Serialize(stream, settings);
return true;
}
serializer.Serialize(stream, settings);
return true;
}

return false;
Expand Down
4 changes: 4 additions & 0 deletions StuntBonusV/StuntBonusV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public StuntBonusScript()
{
throw new InvalidOperationException("The Internal setting path string is empty!");
}
if (!Directory.Exists(Util.SettingRootPath))
{
Directory.CreateDirectory(Util.SettingRootPath);
}

var settingFilePath = Util.SettingRootPath + Path.DirectorySeparatorChar + SettingFileName;
var loader = new SettingLoader<T>();
Expand Down

0 comments on commit d3bf089

Please sign in to comment.