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>
32 lines
986 B
Go
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)
|
|
}
|