Method: Debian::AptPkg::Configuration.config_find_file

Defined in:
ext/apt_pkg/configuration.cpp

.config_find_file(name, default_key = '') ⇒ String

Locate the given key using find() and return the path to the file/directory. This uses a special algorithms which moves upwards in the configuration space and prepends the values of the options to the result. These methods are generally used for the options stored in the ‘Dir’ section of the configuration.

Params:

name

Key name.

default_key

Default key when config option not set.

Debian::AptPkg::Configuration.config_find_file('Dir::Etc::main') # => "/etc/apt/apt.conf"

Returns:

  • (String)
[View source]

151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'ext/apt_pkg/configuration.cpp', line 151

static VALUE
config_find_file(int argc, VALUE *argv, VALUE self)
{
  if (argc > 2 || argc == 0) {
    rb_raise(rb_eArgError, "wrong number of arguments");
  }
  VALUE name, default_key;
  rb_scan_args(argc, argv, "11", &name, &default_key);
  if (NIL_P(default_key))
    default_key = rb_str_new2("");
  return rb_str_new2(_config->FindFile(StringValuePtr(name),
                                       StringValuePtr(default_key)).c_str());
}