From 4b7d616862dc7d8c73561b85deb0ca1fabf30781 Mon Sep 17 00:00:00 2001 From: Ophestra Umiker Date: Tue, 17 Sep 2024 13:48:42 +0900 Subject: exit: move final and early code to internal package Exit cleanup state information is now stored in a dedicated struct and built up using methods of that struct. Signed-off-by: Ophestra Umiker --- internal/state/data.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'internal/state/data.go') diff --git a/internal/state/data.go b/internal/state/data.go index 65b6395e..45493885 100644 --- a/internal/state/data.go +++ b/internal/state/data.go @@ -4,6 +4,8 @@ import ( "encoding/gob" "os" "path" + + "git.ophivana.moe/cat/fortify/internal" ) // we unfortunately have to assume there are never races between processes @@ -14,10 +16,12 @@ type launcherState struct { Launcher string Argv []string Command []string - Capability Enablements + Capability internal.Enablements } -func ReadLaunchers(runDirPath, uid string) ([]*launcherState, error) { +// ReadLaunchers reads all launcher state file entries for the requested user +// and if decode is true decodes these launchers as well. +func ReadLaunchers(runDirPath, uid string, decode bool) ([]*launcherState, error) { var f *os.File var r []*launcherState launcherPrefix := path.Join(runDirPath, uid) @@ -39,7 +43,11 @@ func ReadLaunchers(runDirPath, uid string) ([]*launcherState, error) { var s launcherState r = append(r, &s) - return gob.NewDecoder(f).Decode(&s) + if decode { + return gob.NewDecoder(f).Decode(&s) + } else { + return nil + } } }(); err != nil { return nil, err -- cgit v1.3.1