Module: Mount::OptionString
- Defined in:
- lib/rbmount/string.rb
Class Method Summary collapse
- .append_option(optstr = nil, name, value) ⇒ Object
- .apply_flags(optstr = nil, flags, map) ⇒ Object
- .each_option(optstr) ⇒ Object
- .flags(optstr, map) ⇒ Object
- .option(optstr, name) ⇒ Object
- .options(optstr, map, ignore = 0) ⇒ Object
- .prepend_option(optstr = nil, name, value) ⇒ Object
- .remove_option(optstr = nil, name) ⇒ Object
- .set_option(optstr, name, value = nil) ⇒ Object
- .split_optstr(optstr, ignore_user = 0, ignore_vfs = 0) ⇒ Object
Instance Method Summary collapse
- #append_option(name, value) ⇒ Object
- #apply_flags(flags, map) ⇒ Object
- #each_option(&blk) ⇒ Object
- #flags(map) ⇒ Object
- #option(name) ⇒ Object
- #options(map, ignore = 0) ⇒ Object
- #prepend_option(name, value) ⇒ Object
- #remove_option(name) ⇒ Object
- #set_option(name, value = nil) ⇒ Object
- #split_optstr(ignore_user = 0, ignore_vfs = 0) ⇒ Object
Class Method Details
.append_option(optstr = nil, name, value) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/rbmount/string.rb', line 25 def append_option (optstr=nil, name, value) sptr = optstr.is_a?(::String) ? FFI::MemoryPointer.from_string(optstr) : FFI::MemoryPointer.new(:string) ptr = FFI::MemoryPointer.new(:pointer).write_pointer(sptr) raise unless Mount::C.mnt_optstr_append_option(ptr, name, value) ptr.read_pointer.read_string end |
.apply_flags(optstr = nil, flags, map) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/rbmount/string.rb', line 33 def apply_flags (optstr=nil, flags, map) sptr = optstr.is_a?(::String) ? FFI::MemoryPointer.from_string(optstr) : FFI::MemoryPointer.new(:string) ptr = FFI::MemoryPointer.new(:pointer).write_pointer(sptr) raise unless Mount::C.mnt_optstr_apply_flags(ptr, flags, FFI::MemoryPointer.from_array_of_libmnt_optmap(map)) ptr.read_pointer.read_string end |
.each_option(optstr) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/rbmount/string.rb', line 64 def each_option (optstr) optstr = FFI::MemoryPointer.new(:pointer).write_pointer(FFI::MemoryPointer.from_string(optstr)) Enumerator.new {|y| loop { res = Mount::String.next_option(optstr) break unless res y << res } }.each {|args| yield *args if block_given? } end |
.flags(optstr, map) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/rbmount/string.rb', line 41 def flags (optstr, map) optstr = FFI::MemoryPointer.new(:string).write_string(optstr) ptr = FFI::MemoryPointer.new(:ulong) raise unless Mount::C.mnt_optstr_get_flags(optstr, ptr, FFI::MemoryPointer.from_array_of_libmnt_optmap(map)) ptr.read_ulong end |
.option(optstr, name) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/rbmount/string.rb', line 49 def option (optstr, name) ptr = FFI::MemoryPointer.new(:pointer) ol = FFI::MemoryPointer.new(:ulong) raise unless Mount::C.mnt_optstr_get_option(optstr, name, ptr, ol) ptr.read_pointer.read_string[0, ol.read_ulong] end |
.options(optstr, map, ignore = 0) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/rbmount/string.rb', line 57 def (optstr, map, ignore=0) ptr = FFI::MemoryPointer.new(:pointer) raise unless Mount::C.(optstr, ptr, FFI::MemoryPointer.from_array_of_libmnt_optmap(map), ignore) ptr.read_pointer.read_string end |
.prepend_option(optstr = nil, name, value) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/rbmount/string.rb', line 78 def prepend_option (optstr=nil, name, value) sptr = optstr.is_a?(::String) ? FFI::MemoryPointer.from_string(optstr) : FFI::MemoryPointer.new(:string) ptr = FFI::MemoryPointer.new(:pointer).write_pointer(sptr) raise unless Mount::C.mnt_optstr_prepend_option(ptr, name, value) ptr.read_pointer.read_string end |
.remove_option(optstr = nil, name) ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/rbmount/string.rb', line 86 def remove_option (optstr=nil, name) sptr = optstr.is_a?(::String) ? FFI::MemoryPointer.from_string(optstr) : FFI::MemoryPointer.new(:string) ptr = FFI::MemoryPointer.new(:pointer).write_pointer(sptr) raise unless Mount::C.mnt_optstr_remove_option(ptr, name) ptr.read_pointer.read_string end |
.set_option(optstr, name, value = nil) ⇒ Object
94 95 96 97 98 99 100 |
# File 'lib/rbmount/string.rb', line 94 def set_option (optstr, name, value=nil) sptr = optstr.is_a?(::String) ? FFI::MemoryPointer.from_string(optstr) : FFI::MemoryPointer.new(:string) ptr = FFI::MemoryPointer.new(:pointer).write_pointer(sptr) raise unless Mount::C.mnt_optstr_set_option(ptr, name, value) ptr.read_pointer.read_string end |
.split_optstr(optstr, ignore_user = 0, ignore_vfs = 0) ⇒ Object
102 103 104 105 106 |
# File 'lib/rbmount/string.rb', line 102 def split_optstr (optstr, ignore_user=0, ignore_vfs=0) pi = (1..3).map { FFI::MemoryPointer.new(:pointer).write_pointer(FFI::MemoryPointer.new(:string)) } raise unless Mount::C.mnt_split_optstr(optstr, *pi, ignore_user, ignore_vfs) pi.map {|x| x.read_pointer.read_string } end |
Instance Method Details
#append_option(name, value) ⇒ Object
126 127 128 |
# File 'lib/rbmount/string.rb', line 126 def append_option (name, value) self.replace(Mount::OptionString.append_option(self, name, value)) end |
#apply_flags(flags, map) ⇒ Object
130 131 132 |
# File 'lib/rbmount/string.rb', line 130 def apply_flags (flags, map) self.replace(Mount::OptionString.apply_flags(self, flags, map)) end |
#each_option(&blk) ⇒ Object
146 147 148 |
# File 'lib/rbmount/string.rb', line 146 def each_option (&blk) Mount::OptionString.each_option(self, &blk) end |
#flags(map) ⇒ Object
134 135 136 |
# File 'lib/rbmount/string.rb', line 134 def flags (map) Mount::OptionString.flags(self, map) end |
#option(name) ⇒ Object
138 139 140 |
# File 'lib/rbmount/string.rb', line 138 def option (name) Mount::OptionString.option(self, name) end |
#options(map, ignore = 0) ⇒ Object
142 143 144 |
# File 'lib/rbmount/string.rb', line 142 def (map, ignore=0) Mount::OptionString.(self, map, ignore) end |
#prepend_option(name, value) ⇒ Object
150 151 152 |
# File 'lib/rbmount/string.rb', line 150 def prepend_option (name, value) self.replace(Mount::OptionString.prepend_option(self, name, value)) end |
#remove_option(name) ⇒ Object
154 155 156 |
# File 'lib/rbmount/string.rb', line 154 def remove_option (name) self.replace(Mount::OptionString.remove_option(self, name)) end |
#set_option(name, value = nil) ⇒ Object
158 159 160 |
# File 'lib/rbmount/string.rb', line 158 def set_option (name, value=nil) self.replace(Mount::OptionString.set_option(self, name, value)) end |
#split_optstr(ignore_user = 0, ignore_vfs = 0) ⇒ Object
162 163 164 |
# File 'lib/rbmount/string.rb', line 162 def split_optstr (ignore_user=0, ignore_vfs=0) Mount::OptionString.split_optstr(self, ignore_user, ignore_vfs) end |