Aetheria/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonFrameStore.cs
2026-06-28 05:08:36 +01:00

32 lines
1.1 KiB
C#

using System;
using System.IO;
#nullable enable
namespace GameCult.Aetheria.State.Verse
{
public static class AetheriaRuntimeDaemonFrameStore
{
public static string GetFramePath(string stateFilePath)
{
if (string.IsNullOrWhiteSpace(stateFilePath))
throw new ArgumentException("State file path must be non-empty.", nameof(stateFilePath));
return AetheriaRuntimeStateBoundary.GetDaemonFramePath(stateFilePath);
}
public static string PublishFrame(string stateFilePath, AetheriaRuntimeDaemonFrameDocument frame)
{
if (frame == null) throw new ArgumentNullException(nameof(frame));
frame.Schema = AetheriaRuntimeDaemonSchemas.Frame;
if (string.IsNullOrWhiteSpace(frame.PublishedAtUtc))
frame.PublishedAtUtc = DateTime.UtcNow.ToString("O");
var framePath = GetFramePath(stateFilePath);
Directory.CreateDirectory(Path.GetDirectoryName(framePath) ?? ".");
AetheriaRuntimeCultCacheDocumentStore.WriteDaemonFrame(framePath, frame);
return framePath;
}
}
}