diff --git a/.gitignore b/.gitignore index 6a7dea2..5a2e5b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ /cmutton.a /cmutton.h -/test.c +/testc /a.out diff --git a/README.md b/README.md index fc24a26..7121af7 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Build the C library + headers w/`go build -buildmode=c-archive`. - [ ] global - [X] DirInit(preserveOldCfgDir bool) (string, error) - [ ] ~~GenDeviceIDList() ([]fs.DirEntry, error)~~ - - [ ] GetCurrentDeviceID() (string, error) + - [X] GetCurrentDeviceID() (string, error) - [ ] GetRealAgePath(vanityPath string) string - [ ] GetRealPath(vanityPath string) string - [ ] GetSysProcAttr() *syscall.SysProcAttr diff --git a/global.go b/global.go index 240b29d..fbaaa86 100644 --- a/global.go +++ b/global.go @@ -9,7 +9,7 @@ import ( ) // DirInit returns: -// r0: oldDeviceID (special case: see libmutton docs) +// r0: oldDeviceID (FSMisc if none) // // r1: err // @@ -22,4 +22,18 @@ func DirInit(preserveOldCfgDir bool) (*C.char, *C.char) { 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() {}