diff --git a/StarterNG.Tests/Fakes/InMemoryFileSystem.cs b/StarterNG.Tests/Fakes/InMemoryFileSystem.cs
index e95f021..79108cb 100644
--- a/StarterNG.Tests/Fakes/InMemoryFileSystem.cs
+++ b/StarterNG.Tests/Fakes/InMemoryFileSystem.cs
@@ -200,6 +200,9 @@ public sealed class InMemoryFileSystem : IFileSystem
/// Files added through carry the execute bit.
public long GetFileSize(string path) => Bytes(path).LongLength;
+ public (DateTime LastWriteUtc, long Size)? LastWriteAndSize(string path) =>
+ FileExists(path) ? (GetLastWriteTimeUtc(path), GetFileSize(path)) : null;
+
public bool IsExecutable(string path) => _executable.Contains(Normalize(path));
public InMemoryFileSystem WithExecutable(string path, string contents = "\u007fELF")
diff --git a/StarterNG/Application/Abstractions/IFileSystem.cs b/StarterNG/Application/Abstractions/IFileSystem.cs
index 66e8ca3..e04f862 100644
--- a/StarterNG/Application/Abstractions/IFileSystem.cs
+++ b/StarterNG/Application/Abstractions/IFileSystem.cs
@@ -55,6 +55,9 @@ public interface IFileSystem
long GetFileSize(string path);
+ /// A file's time and size in one look; null when there is no file.
+ (DateTime LastWriteUtc, long Size)? LastWriteAndSize(string path);
+
bool IsExecutable(string path);
/// Where the symbolic link at points, or null for anything else.
diff --git a/StarterNG/Domain/Sceneries/FileStamp.cs b/StarterNG/Domain/Sceneries/FileStamp.cs
index 674bca0..f892461 100644
--- a/StarterNG/Domain/Sceneries/FileStamp.cs
+++ b/StarterNG/Domain/Sceneries/FileStamp.cs
@@ -11,9 +11,7 @@ public readonly record struct FileStamp(DateTime LastWriteUtc, long Size)
{
try
{
- return files.FileExists(path)
- ? new FileStamp(files.GetLastWriteTimeUtc(path), files.GetFileSize(path))
- : null;
+ return files.LastWriteAndSize(path) is { } stat ? new FileStamp(stat.LastWriteUtc, stat.Size) : null;
}
catch (Exception)
{
diff --git a/StarterNG/Infrastructure/Adapters/PhysicalFileSystem.cs b/StarterNG/Infrastructure/Adapters/PhysicalFileSystem.cs
index db9350d..15ae4ee 100644
--- a/StarterNG/Infrastructure/Adapters/PhysicalFileSystem.cs
+++ b/StarterNG/Infrastructure/Adapters/PhysicalFileSystem.cs
@@ -110,6 +110,12 @@ public sealed class PhysicalFileSystem : IFileSystem
public long GetFileSize(string path) => new FileInfo(path).Length;
+ public (DateTime LastWriteUtc, long Size)? LastWriteAndSize(string path)
+ {
+ var info = new FileInfo(path);
+ return info.Exists ? (info.LastWriteTimeUtc, info.Length) : null;
+ }
+
public bool IsExecutable(string path)
{
if (OperatingSystem.IsWindows())