diff --git a/src/AcDream.Platform/ApplicationPathSet.cs b/src/AcDream.Platform/ApplicationPathSet.cs index a6743ad1..76e3a1f5 100644 --- a/src/AcDream.Platform/ApplicationPathSet.cs +++ b/src/AcDream.Platform/ApplicationPathSet.cs @@ -72,6 +72,16 @@ public sealed record ApplicationPathSet( { platform ??= ApplicationPathEnvironment.Instance; + // Explicit method/CLI arguments remain authoritative. The environment + // seam lets graphical automation and portable installations isolate + // all mutable user state without rewriting the real user's settings. + configDirectory ??= NonEmpty( + platform.GetEnvironmentVariable("ACDREAM_CONFIG_DIR")); + dataDirectory ??= NonEmpty( + platform.GetEnvironmentVariable("ACDREAM_DATA_DIR")); + cacheDirectory ??= NonEmpty( + platform.GetEnvironmentVariable("ACDREAM_CACHE_DIR")); + string config; string data; string cache; @@ -140,6 +150,9 @@ public sealed record ApplicationPathSet( return Path.Combine(root, leaf); } + private static string? NonEmpty(string? value) => + string.IsNullOrWhiteSpace(value) ? null : value; + private static string RequireFolder( IApplicationPathEnvironment platform, Environment.SpecialFolder folder)