Re-add Feature#sysdef!
This commit is contained in:
parent
bd0d8c4cd9
commit
c3874d7dae
2 changed files with 38 additions and 0 deletions
|
@ -44,6 +44,28 @@ ffi_available_features(VALUE self)
|
|||
return features;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
ffi_reset(VALUE self, VALUE rb_feature, VALUE rb_path)
|
||||
{
|
||||
VALUE rb_enable_flag, rb_disable_flag;
|
||||
char *enable_flag, *disable_flag, *path;
|
||||
|
||||
rb_enable_flag = rb_funcall(rb_feature, rb_intern("enable"), 0);
|
||||
rb_disable_flag = rb_funcall(rb_feature, rb_intern("disable"), 0);
|
||||
Check_Type(rb_path, T_STRING);
|
||||
Check_Type(rb_enable_flag, T_STRING);
|
||||
Check_Type(rb_disable_flag, T_STRING);
|
||||
path = RSTRING_PTR(rb_path);
|
||||
enable_flag = RSTRING_PTR(rb_enable_flag);
|
||||
disable_flag = RSTRING_PTR(rb_disable_flag);
|
||||
if(hbsdcontrol_extattr_rm_attr(path, disable_flag) == 0 ||
|
||||
hbsdcontrol_extattr_rm_attr(path, enable_flag) == 0) {
|
||||
return Qtrue;
|
||||
} else {
|
||||
return Qfalse;
|
||||
}
|
||||
}
|
||||
|
||||
static VALUE
|
||||
feature_set(VALUE self, VALUE path, VALUE state)
|
||||
{
|
||||
|
@ -83,5 +105,6 @@ Init_hbsdctl(void)
|
|||
rb_define_const(rb_mControl, "Enable", INT2NUM(1));
|
||||
rb_define_singleton_method(rb_mFFI, "available_features", ffi_available_features, 0);
|
||||
rb_define_singleton_method(rb_mFFI, "library_version", ffi_library_version, 0);
|
||||
rb_define_singleton_method(rb_mFFI, "reset!", ffi_reset, 2);
|
||||
rb_define_private_method(rb_cFeature, "set!", feature_set, 2);
|
||||
}
|
||||
|
|
|
@ -40,6 +40,21 @@ module BSD::Control
|
|||
set!(path, BSD::Control::Disable)
|
||||
end
|
||||
|
||||
##
|
||||
# Restore system defaults.
|
||||
#
|
||||
# @param [String] path
|
||||
# The path to a file.
|
||||
#
|
||||
# @raise [BSD::Control::Error]
|
||||
# When the operation fails.
|
||||
#
|
||||
# @return [Boolean]
|
||||
# Returns true on success.
|
||||
def sysdef!(path)
|
||||
FFI.reset!(self, path)
|
||||
end
|
||||
|
||||
# @endgroup
|
||||
|
||||
##
|
||||
|
|
Loading…
Reference in a new issue