同步本地代码

This commit is contained in:
lx1056758714-glitch
2025-12-13 17:30:38 +08:00
parent 76fa3b4538
commit 3d04a7f3eb
150 changed files with 23690 additions and 0 deletions
+41
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
}