mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-19 06:55:59 +01:00
fix: open a scenery's attachments whatever the case of their names
A //$f attachment is looked up from the game folder through the new AttachmentLocator, so on Linux its button is enabled and opens the file when the scenery names it in other letter case or with backslashes.
This commit is contained in:
24
StarterNG/Infrastructure/Sceneries/AttachmentLocator.cs
Normal file
24
StarterNG/Infrastructure/Sceneries/AttachmentLocator.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using StarterNG.Application.Abstractions;
|
||||
using StarterNG.Domain.Sceneries;
|
||||
|
||||
namespace StarterNG.Infrastructure.Sceneries;
|
||||
|
||||
/// <summary>Where the file a scenery attaches (<c>//$f</c>) is on disk.</summary>
|
||||
public sealed class AttachmentLocator
|
||||
{
|
||||
private readonly IGamePaths _paths;
|
||||
private readonly CaseInsensitivePaths _names;
|
||||
|
||||
public AttachmentLocator(IFileSystem files, IGamePaths paths)
|
||||
{
|
||||
_paths = paths;
|
||||
_names = new CaseInsensitivePaths(files);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The attachment's file, named from the game's folder or in full, with its letters
|
||||
/// as on disk; null when it is not there.
|
||||
/// </summary>
|
||||
public string? Resolve(SceneryAttachment attachment) =>
|
||||
string.IsNullOrWhiteSpace(attachment.FilePath) ? null : _names.Find(_paths.Root, attachment.FilePath.Trim());
|
||||
}
|
||||
Reference in New Issue
Block a user