initial commit
This commit is contained in:
37
StateTracker.cs
Normal file
37
StateTracker.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
namespace Toak;
|
||||
|
||||
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