Files
Reims-Go/internal/macos/reims/release_record.go
T
NwflowerandClaude Opus 5.5 b203bde650 refactor: merge duplicated helpers and the window event contract
Events to the frontend go through App.emit, and a test keeps their names
in step with wails.ts. QEMU argument splitting, hidden console processes,
the macOS release record, the running check and a few smaller helpers
now exist once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 21:09:19 -07:00

32 lines
986 B
Go

package reims
import (
"os"
"path/filepath"
"strings"
)
// releaseRecordFile records which macOS release a VM was created with, for its
// icon. reims-ctl keeps no such field in vm.toml.
const releaseRecordFile = ".reims-go-macos"
// ReadReleaseRecord returns the macOS release recorded in dir: an installer
// version such as "26.7.3", or a codename such as "tahoe" for an
// online-recovery install. It is "" when none was recorded.
func ReadReleaseRecord(dir string) string {
b, err := os.ReadFile(filepath.Join(dir, releaseRecordFile))
if err != nil {
return ""
}
return strings.TrimSpace(string(b))
}
// WriteReleaseRecord stores release next to vm.toml; an empty release writes nothing.
func WriteReleaseRecord(dir, release string) error {
release = strings.TrimSpace(strings.NewReplacer("\r", "", "\n", "").Replace(release))
if dir == "" || release == "" {
return nil
}
return os.WriteFile(filepath.Join(dir, releaseRecordFile), []byte(release+"\n"), 0o644)
}