This commit is contained in:
Shen Junzheng
2025-03-21 21:45:08 +08:00
parent 78cce92ce3
commit 80c7e67106
86 changed files with 7061 additions and 2316 deletions

View File

@@ -0,0 +1,41 @@
package appver
import (
"os"
"path/filepath"
"strconv"
"strings"
"howett.net/plist"
)
const (
InfoFile = "Info.plist"
)
type Plist struct {
CFBundleShortVersionString string `plist:"CFBundleShortVersionString"`
NSHumanReadableCopyright string `plist:"NSHumanReadableCopyright"`
}
func (i *Info) initialize() error {
parts := strings.Split(i.FilePath, string(filepath.Separator))
file := filepath.Join(append(parts[:len(parts)-2], InfoFile)...)
b, err := os.ReadFile("/" + file)
if err != nil {
return err
}
p := Plist{}
_, err = plist.Unmarshal(b, &p)
if err != nil {
return err
}
i.FullVersion = p.CFBundleShortVersionString
i.Version, _ = strconv.Atoi(strings.Split(i.FullVersion, ".")[0])
i.CompanyName = p.NSHumanReadableCopyright
return nil
}