Module: Xattr::Lib
- Extended by:
- FFI::Library
- Defined in:
- lib/ffi-xattr/linux_lib.rb,
lib/ffi-xattr/darwin_lib.rb,
lib/ffi-xattr/windows_lib.rb
Constant Summary collapse
- XATTR_NOFOLLOW =
0x0001
Class Method Summary collapse
- .get(path, no_follow, key) ⇒ Object
- .list(path, no_follow) ⇒ Object
- .remove(path, no_follow, key) ⇒ Object
- .set(path, no_follow, key, value) ⇒ Object
Class Method Details
.get(path, no_follow, key) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ffi-xattr/linux_lib.rb', line 29 def get(path, no_follow, key) method = no_follow ? :lgetxattr : :getxattr size = send(method, path, key, nil, 0) return unless size > 0 str_ptr = FFI::MemoryPointer.new(:char, size) send(method, path, key, str_ptr, size) str_ptr.read_string(size) end |
.list(path, no_follow) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/ffi-xattr/linux_lib.rb', line 20 def list(path, no_follow) method = no_follow ? :llistxattr : :listxattr size = send(method, path, nil, 0) res_ptr = FFI::MemoryPointer.new(:pointer, size) send(method, path, res_ptr, size) res_ptr.read_string(size).split("\000") end |