Files
StarterNG/StarterNG/Domain/SimulatorNames.cs
maj00r 69aa075bfa Keep scenery files intact on save and follow them on disk
Saves keep comments and every byte they do not change. Faults in a scenery's
text are found and described. Files that change while the starter runs are
picked up without a manual reload.
2026-11-01 16:06:15 +01:00

19 lines
727 B
C#

namespace StarterNG.Domain;
/// <summary>
/// File names as the simulator makes them: its parser folds every word it reads
/// to lower case - ASCII letters only - the files a scenery includes and the
/// scenario given with <c>-s</c> among them, and opens the file by that name.
/// Where letter case counts, as on Linux, a file is found only when it is named
/// so on disk.
/// </summary>
public static class SimulatorNames
{
public static string Lower(string name) =>
string.Create(name.Length, name, static (folded, source) =>
{
for (int i = 0; i < source.Length; i++)
folded[i] = source[i] is >= 'A' and <= 'Z' ? (char)(source[i] + ('a' - 'A')) : source[i];
});
}