blob: 602053dc18a9821f3634f5c7ebcd6c3fa739fb4d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
class Xattr # :nodoc: all
module Error
extend FFI::Library
ffi_lib "c"
attach_function :strerror_r, [:int, :pointer, :size_t], :int unless RUBY_PLATFORM =~ /mingw/
class << self
def last
errno = FFI.errno
ptr = FFI::MemoryPointer.new(:char, 256)
strerror_r(errno, ptr, 256)
[ ptr.read_string, errno ]
end
def check(int)
raise SystemCallError.new(*last) if int != 0
end
end
end
end
|