Refactor: Reorganize project structure by moving core components into dedicated directories and introducing new configuration and API models.
This commit is contained in:
37
Core/StateTracker.cs
Normal file
37
Core/StateTracker.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
namespace Toak.Core;
|
||||
|
||||
public static class StateTracker
|
||||
{
|
||||
private static readonly string StateFilePath = Path.Combine(Path.GetTempPath(), "toak_state.pid");
|
||||
|
||||
public static bool IsRecording()
|
||||
{
|
||||
return File.Exists(StateFilePath);
|
||||
}
|
||||
|
||||
public static void SetRecording(int ffmpegPid)
|
||||
{
|
||||
File.WriteAllText(StateFilePath, ffmpegPid.ToString());
|
||||
}
|
||||
|
||||
public static int? GetRecordingPid()
|
||||
{
|
||||
if (File.Exists(StateFilePath))
|
||||
{
|
||||
var content = File.ReadAllText(StateFilePath).Trim();
|
||||
if (int.TryParse(content, out var pid))
|
||||
{
|
||||
return pid;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void ClearRecording()
|
||||
{
|
||||
if (File.Exists(StateFilePath))
|
||||
{
|
||||
File.Delete(StateFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user