Port GetCurrentDeviceID()

This commit is contained in:
2026-01-21 00:26:42 -05:00
parent 65252fd353
commit 52cb51dd75
3 changed files with 17 additions and 3 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
/cmutton.a /cmutton.a
/cmutton.h /cmutton.h
/test.c /testc
/a.out /a.out
+1 -1
View File
@@ -36,7 +36,7 @@ Build the C library + headers w/`go build -buildmode=c-archive`.
- [ ] global - [ ] global
- [X] DirInit(preserveOldCfgDir bool) (string, error) - [X] DirInit(preserveOldCfgDir bool) (string, error)
- [ ] ~~GenDeviceIDList() ([]fs.DirEntry, error)~~ - [ ] ~~GenDeviceIDList() ([]fs.DirEntry, error)~~
- [ ] GetCurrentDeviceID() (string, error) - [X] GetCurrentDeviceID() (string, error)
- [ ] GetRealAgePath(vanityPath string) string - [ ] GetRealAgePath(vanityPath string) string
- [ ] GetRealPath(vanityPath string) string - [ ] GetRealPath(vanityPath string) string
- [ ] GetSysProcAttr() *syscall.SysProcAttr - [ ] GetSysProcAttr() *syscall.SysProcAttr
+15 -1
View File
@@ -9,7 +9,7 @@ import (
) )
// DirInit returns: // DirInit returns:
// r0: oldDeviceID (special case: see libmutton docs) // r0: oldDeviceID (FSMisc if none)
// //
// r1: err // r1: err
// //
@@ -22,4 +22,18 @@ func DirInit(preserveOldCfgDir bool) (*C.char, *C.char) {
return C.CString(oldDeviceID), nil return C.CString(oldDeviceID), nil
} }
// GetCurrentDeviceID returns:
// r0: currentDeviceID (FSMisc if none)
//
// r1: err
//
//export GetCurrentDeviceID
func GetCurrentDeviceID() (*C.char, *C.char) {
currentDeviceID, err := global.GetCurrentDeviceID()
if err != nil {
return nil, C.CString(err.Error())
}
return C.CString(currentDeviceID), nil
}
func main() {} func main() {}