Skip to content
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

Merged
merged 9 commits into from
Jun 20, 2014
Merged

JNA wrapper for <sys/xattr.h> #338

merged 9 commits into from
Jun 20, 2014

Conversation

rednoah
Copy link
Contributor

@rednoah rednoah commented Jun 18, 2014

Here is my wrapper for <sys/xattr.h> with support for xattr list/get/set/remove.

Tested on OS X 10.9.2

@twall
Copy link
Contributor

twall commented Jun 18, 2014

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) {
Copy link
Contributor

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().

Copy link
Contributor Author

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?

Copy link
Contributor

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
@rednoah
Copy link
Contributor Author

rednoah commented Jun 18, 2014

ok, fixed changes and null

twall added a commit that referenced this pull request Jun 20, 2014
JNA wrapper for <sys/xattr.h>
@twall twall merged commit 33dcdb0 into java-native-access:master Jun 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants