package exec import ( "errors" "fmt" wasiv1 "code.icb4dc0.de/buildr/api/generated/wasi/v1" "code.icb4dc0.de/buildr/wasi-module-sdk-go/mem" ) func LookPath(file string) (string, error) { lookupPathReq := &wasiv1.LookupPathRequest{ Command: file, } data, err := lookupPathReq.MarshalVT() if err != nil { return "", err } result := _lookPath(mem.DataToManagedPtr(data)) if result == 0 { return "", fmt.Errorf("failed to lookup in path: %s", file) } resultPtr := uint32(result >> 32) resultSize := uint32(result) if resultSize == 0 { return "", fmt.Errorf("failed to lookup in path: %s", file) } lookupPathResp := new(wasiv1.LookupPathResponse) if err := lookupPathResp.UnmarshalVT(mem.PtrToData(resultPtr, resultSize)); err != nil { return "", err } if len(lookupPathResp.Error) > 0 { return "", errors.New(lookupPathResp.Error) } return lookupPathResp.Path, nil }