mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-07-22 06:28:00 +08:00
Add the production-facing official update service and bat-official-sync watch CLI for unattended resource synchronization. Support launcher-resource discovery without installing the launcher, remote marker snapshots, local manifest audit and repair, official seed hash validation, bootstrap caching, richer Addressables coverage, SQLite resource persistence, and FFI JSON helpers.
58 lines
1.5 KiB
Go
58 lines
1.5 KiB
Go
package ffi
|
|
|
|
/*
|
|
#cgo CFLAGS: -I${SRCDIR}/../../target/bat-ffi
|
|
#cgo LDFLAGS: -L${SRCDIR}/../../target/debug -lbat_ffi
|
|
#include <stdlib.h>
|
|
|
|
typedef char* ccharp;
|
|
extern const char* bat_version();
|
|
extern void bat_free_string(char* s);
|
|
extern char* bat_manifest_inspect_json(const char* raw_json);
|
|
extern char* bat_sync_plan_json(const char* current_json, const char* previous_json);
|
|
*/
|
|
import "C"
|
|
import (
|
|
"errors"
|
|
"unsafe"
|
|
)
|
|
|
|
func Version() (string, error) {
|
|
ptr := C.bat_version()
|
|
if ptr == nil {
|
|
return "", errors.New("bat_version returned nil")
|
|
}
|
|
defer C.bat_free_string((*C.char)(unsafe.Pointer(ptr)))
|
|
return C.GoString(ptr), nil
|
|
}
|
|
|
|
func InspectManifest(rawJSON string) (string, error) {
|
|
cRaw := C.CString(rawJSON)
|
|
defer C.free(unsafe.Pointer(cRaw))
|
|
|
|
ptr := C.bat_manifest_inspect_json(cRaw)
|
|
if ptr == nil {
|
|
return "", errors.New("bat_manifest_inspect_json returned nil")
|
|
}
|
|
defer C.bat_free_string((*C.char)(unsafe.Pointer(ptr)))
|
|
return C.GoString(ptr), nil
|
|
}
|
|
|
|
func BuildSyncPlan(currentJSON, previousJSON string) (string, error) {
|
|
cCurrent := C.CString(currentJSON)
|
|
defer C.free(unsafe.Pointer(cCurrent))
|
|
|
|
var cPrevious *C.char
|
|
if previousJSON != "" {
|
|
cPrevious = C.CString(previousJSON)
|
|
defer C.free(unsafe.Pointer(cPrevious))
|
|
}
|
|
|
|
ptr := C.bat_sync_plan_json(cCurrent, cPrevious)
|
|
if ptr == nil {
|
|
return "", errors.New("bat_sync_plan_json returned nil")
|
|
}
|
|
defer C.bat_free_string((*C.char)(unsafe.Pointer(ptr)))
|
|
return C.GoString(ptr), nil
|
|
}
|