ffi-xattr 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/lib/ffi-xattr/error.rb +1 -1
- data/lib/ffi-xattr/freebsd_lib.rb +62 -0
- data/lib/ffi-xattr/version.rb +1 -1
- data/lib/ffi-xattr.rb +2 -0
- data/spec/xattr_spec.rb +1 -1
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4e89f2e515824d33bf4cfe74b95eea1526e35092c669bb5f4280c8d4c86071d4
|
4
|
+
data.tar.gz: 3369d3f39135d5176d1b24077eb380ff5140aa78498ccbd9f0b0291d2c36484c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea47fac5b6f82cf0c065724f3283bb72fe81f0636eb9613be1e7f89f42066e52cc038a8fa2d00ee12b8faa88f74dbb830f795eea1144ec7943f18bb40c134ef1
|
7
|
+
data.tar.gz: fd88cae5f42ca84e36214b76c82afedfd367c5e60e3767d786221ec62dbf95d9c9ea6ccf4e395ea55a2be9a66524bc015edad49b744505d7dcfca239b720145a
|
data/.gitignore
CHANGED
data/lib/ffi-xattr/error.rb
CHANGED
@@ -0,0 +1,62 @@
|
|
1
|
+
class Xattr # :nodoc: all
|
2
|
+
module Lib
|
3
|
+
extend FFI::Library
|
4
|
+
|
5
|
+
ffi_lib "c"
|
6
|
+
|
7
|
+
EXTATTR_NAMESPACE_USER = 1
|
8
|
+
|
9
|
+
attach_function :extattr_list_file, [:string, :int, :pointer, :size_t], :ssize_t
|
10
|
+
attach_function :extattr_set_file, [:string, :int, :string, :pointer, :size_t], :ssize_t
|
11
|
+
attach_function :extattr_get_file, [:string, :int, :string, :pointer, :size_t], :ssize_t
|
12
|
+
attach_function :extattr_delete_file, [:string, :int, :string], :ssize_t
|
13
|
+
|
14
|
+
attach_function :extattr_list_link, [:string, :int, :pointer, :size_t], :ssize_t
|
15
|
+
attach_function :extattr_set_link, [:string, :int, :string, :pointer, :size_t], :ssize_t
|
16
|
+
attach_function :extattr_get_link, [:string, :int, :string, :pointer, :size_t], :ssize_t
|
17
|
+
attach_function :extattr_delete_link, [:string, :int, :string], :ssize_t
|
18
|
+
|
19
|
+
class << self
|
20
|
+
def list(path, no_follow)
|
21
|
+
method = no_follow ? :extattr_list_link : :extattr_list_file
|
22
|
+
size = send(method, path, EXTATTR_NAMESPACE_USER, nil, 0)
|
23
|
+
res_ptr = FFI::MemoryPointer.new(:pointer, size)
|
24
|
+
send(method, path, EXTATTR_NAMESPACE_USER, res_ptr, size)
|
25
|
+
|
26
|
+
res = []
|
27
|
+
bytes = res_ptr.read_string(size).bytes
|
28
|
+
until bytes.empty?
|
29
|
+
size = bytes.shift
|
30
|
+
res << bytes.shift(size).map(&:chr).join
|
31
|
+
end
|
32
|
+
|
33
|
+
res
|
34
|
+
end
|
35
|
+
|
36
|
+
def get(path, no_follow, key)
|
37
|
+
method = no_follow ? :extattr_get_link : :extattr_get_file
|
38
|
+
size = send(method, path, EXTATTR_NAMESPACE_USER, key, nil, 0)
|
39
|
+
return unless size > 0
|
40
|
+
|
41
|
+
str_ptr = FFI::MemoryPointer.new(:char, size)
|
42
|
+
send(method, path, EXTATTR_NAMESPACE_USER, key, str_ptr, size)
|
43
|
+
|
44
|
+
str_ptr.read_string(size)
|
45
|
+
end
|
46
|
+
|
47
|
+
def set(path, no_follow, key, value)
|
48
|
+
method = no_follow ? :extattr_set_link : :extattr_set_file
|
49
|
+
#require 'byebug'
|
50
|
+
#byebug
|
51
|
+
|
52
|
+
Error.check send(method, path, EXTATTR_NAMESPACE_USER, key, value, value.bytesize)
|
53
|
+
end
|
54
|
+
|
55
|
+
def remove(path, no_follow, key)
|
56
|
+
method = no_follow ? :extattr_delete_link : :extattr_delete_file
|
57
|
+
Error.check send(method, path, EXTATTR_NAMESPACE_USER, key)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
data/lib/ffi-xattr/version.rb
CHANGED
data/lib/ffi-xattr.rb
CHANGED
data/spec/xattr_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-xattr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jari Bakken
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- lib/ffi-xattr/extensions.rb
|
73
73
|
- lib/ffi-xattr/extensions/file.rb
|
74
74
|
- lib/ffi-xattr/extensions/pathname.rb
|
75
|
+
- lib/ffi-xattr/freebsd_lib.rb
|
75
76
|
- lib/ffi-xattr/linux_lib.rb
|
76
77
|
- lib/ffi-xattr/version.rb
|
77
78
|
- lib/ffi-xattr/windows_lib.rb
|
@@ -95,12 +96,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
96
|
- !ruby/object:Gem::Version
|
96
97
|
version: '0'
|
97
98
|
requirements: []
|
98
|
-
|
99
|
-
rubygems_version: 2.2.0
|
99
|
+
rubygems_version: 3.0.3.1
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: Manipulate extended file attributes
|
103
103
|
test_files:
|
104
104
|
- spec/extensions_spec.rb
|
105
105
|
- spec/xattr_spec.rb
|
106
|
-
has_rdoc:
|