-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JNA wrapper for <sys/xattr.h> #338
Conversation
Please add a line to CHANGES.md. Otherwise, LGTM. Kudos for including tests. |
return XAttr.INSTANCE.removexattr(path, name, 0); | ||
} | ||
|
||
protected static Memory encodeString(String s) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be some overlap here with Native.toString(byte[])
and Pointer.setString()/setWideString()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if I wanted a Pointer to a NULL-terminated UTF-8 String I'd use Pointer.setString("XYZ", "UTF-8")? In the docs it doesn't explicitly state it will be NULL-terminated. Also String.length() isn't necessarily the byte size once encoded, so will this automatically allocate the necessary memory as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pointer.setString()
does NUL-terminate, but since you need to allocate space here as well, that function doesn't help much. The class NativeString
actually does what you want, but it's package-protected.
I think your code is fine as is.
change notes for the xattr wrapper
reference pull request
fix reference
fix <>
ok, fixed changes and null |
Here is my wrapper for <sys/xattr.h> with support for xattr list/get/set/remove.
Tested on OS X 10.9.2