Skip to content

Commit

Permalink
This is version 1.0.2
Browse files Browse the repository at this point in the history
Create a savefile directory if it does not exist.
  • Loading branch information
teo-tsirpanis committed Jun 13, 2020
1 parent a78b5be commit 4e7844c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DayGame.iss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define MyAppName "DayGame"
#define MyAppVersion "1.0"
#define MyAppVersion "1.0.2"
#define MyAppPublisher "Software Engineering Team 7"
#define MyAppURL "https://github.com/teo-tsirpanis/DayGame"
#define MyAppExeName "DayGame.exe"
Expand Down
4 changes: 2 additions & 2 deletions Source/DayGame.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<Version>1.0.1</Version>
<Version>1.0.2</Version>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<IsPackable>false</IsPackable>
Expand Down
11 changes: 9 additions & 2 deletions Source/Persistence/SaveFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ private SaveFile()
public void Save()
{
_data.UpdateSaveDate();
var directory = Path.GetDirectoryName(FileName);
if (!Directory.Exists(directory))
Directory.CreateDirectory(directory);
File.WriteAllText(FileName, JsonConvert.SerializeObject(_data));
}

Expand Down Expand Up @@ -137,8 +140,11 @@ public static SaveFile OpenExisting(string fileName)
/// <param name="directory">The directory to find. Subdirectories are not searched.</param>
/// <param name="onError">An optional delegate that gets called for every exception during
/// the reading of the file. It accepts the path of the faulty file and the exception's message.</param>
public static SaveFile[] ListSaveFiles(string directory, Action<string, string> onError = null) =>
Directory.EnumerateFiles(directory, "*.daygame").Select(path =>
public static SaveFile[] ListSaveFiles(string directory, Action<string, string> onError = null)
{
if (!Directory.Exists(directory))
return Array.Empty<SaveFile>();
return Directory.EnumerateFiles(directory, "*.daygame").Select(path =>
{
try
{
Expand All @@ -150,6 +156,7 @@ public static SaveFile[] ListSaveFiles(string directory, Action<string, string>
return null;
}
}).Where(x => x != null).ToArray();
}

sealed class TaskConverter : JsonConverter
{
Expand Down

0 comments on commit 4e7844c

Please sign in to comment.