/usr/lib/ruby/vendor_ruby/gir_ffi-base/glib/strv.rb is in ruby-gir-ffi 0.9.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | require 'ffi'
module GLib
# Represents a null-terminated array of strings. GLib uses this
# construction, but does not provide any actual functions for this class.
class Strv
include Enumerable
POINTER_SIZE = FFI.type_size(:pointer)
def initialize(ptr)
@ptr = ptr
end
def to_ptr
@ptr
end
def each
return if @ptr.null?
reset_iterator
while (ptr = next_ptr)
yield ptr.read_string
end
end
def self.wrap(ptr)
new ptr
end
private
def reset_iterator
@offset = 0
end
def next_ptr
ptr = @ptr.get_pointer @offset
@offset += POINTER_SIZE
ptr unless ptr.null?
end
end
end
|