Skip to content

Commit a5c87b3

Browse files
authored
Add additional file exist checks
1 parent 4ead9d6 commit a5c87b3

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

.github/workflows/dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: .NET
22

33
env:
44
PACK_ID: Sims1WidescreenPatcher
5-
PACK_VER: 3.7.1
5+
PACK_VER: 3.7.2
66

77
on:
88
push:

Sims1WidescreenPatcher.Utilities/PatchUtility.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static class PatchUtility
99

1010
public static bool IsValidSims(string path)
1111
{
12-
if (string.IsNullOrWhiteSpace(path)) return false;
12+
if (string.IsNullOrWhiteSpace(path) || !File.Exists(path)) return false;
1313
Log.Information("Begin check Sims executable is valid");
1414
var pattern = Pattern.Transform(BytePattern);
1515
var bytes = File.ReadAllBytes(path);
@@ -53,7 +53,7 @@ public static void Patch(string path, int width, int height)
5353

5454
public static bool SimsBackupExists(string path)
5555
{
56-
if (string.IsNullOrWhiteSpace(path)) return false;
56+
if (string.IsNullOrWhiteSpace(path) || !File.Exists(path)) return false;
5757
Log.Information("Begin check backup exists for Sims executable");
5858
Log.Debug("Path {Path}", path);
5959
var fileName = Path.GetFileNameWithoutExtension(path);
@@ -67,7 +67,7 @@ public static bool SimsBackupExists(string path)
6767

6868
private static void BackupSims(string path)
6969
{
70-
if (string.IsNullOrWhiteSpace(path)) return;
70+
if (string.IsNullOrWhiteSpace(path) || !File.Exists(path)) return;
7171
Log.Information("Begin backup of Sims executable");
7272
var fileName = Path.GetFileNameWithoutExtension(path);
7373
var dir = Path.GetDirectoryName(path) ?? string.Empty;

Sims1WidescreenPatcher.Windows/Services/FindSimsPathService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public string FindSimsPath()
1515
var val = key?.GetValue("InstallPath")?.ToString();
1616
if (string.IsNullOrWhiteSpace(val)) return string.Empty;
1717
var path = Path.Combine(val, "Sims.exe");
18-
return path;
18+
return File.Exists(path) ? path : string.Empty;
1919
}
2020
catch (Exception)
2121
{

0 commit comments

Comments
 (0)