mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-04 05:11:50 +01:00
Look at each source file of a scenery once
The watch of scenery files asked three times per file, whether it is there, its time and its size, every two seconds for every source of every scenery. One look gives all three.
This commit is contained in:
@@ -200,6 +200,9 @@ public sealed class InMemoryFileSystem : IFileSystem
|
||||
/// <summary>Files added through <see cref="WithExecutable"/> carry the execute bit.</summary>
|
||||
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")
|
||||
|
||||
@@ -55,6 +55,9 @@ public interface IFileSystem
|
||||
|
||||
long GetFileSize(string path);
|
||||
|
||||
/// <summary>A file's time and size in one look; null when there is no file.</summary>
|
||||
(DateTime LastWriteUtc, long Size)? LastWriteAndSize(string path);
|
||||
|
||||
bool IsExecutable(string path);
|
||||
|
||||
/// <summary>Where the symbolic link at <paramref name="path"/> points, or null for anything else.</summary>
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user