3 use vars qw($default_dir);
8 FS::Conf - Read access to Freeside configuration values
14 $conf = new FS::Conf "/config/directory";
16 $FS::Conf::default_dir = "/config/directory";
21 $value = $conf->config('key');
22 @list = $conf->config('key');
23 $bool = $conf->exists('key');
27 Read access to Freeside configuration values. Keys currently map to filenames,
28 but this may change in the future.
34 =item new [ DIRECTORY ]
36 Create a new configuration object. A directory arguement is required if
37 $FS::Conf::default_dir has not been set.
43 my($class) = ref($proto) || $proto;
44 my($self) = { 'dir' => $dir || $default_dir } ;
45 bless ($self, $class);
50 Returns the directory.
56 my $dir = $self->{dir};
57 -e $dir or die "FATAL: $dir doesn't exist!";
58 -d $dir or die "FATAL: $dir isn't a directory!";
59 -r $dir or die "FATAL: Can't read $dir!";
60 -x $dir or die "FATAL: $dir not searchable (executable)!";
66 Returns the configuration value or values (depending on context) for key.
73 my $fh = new IO::File "<$dir/$file" or return;
77 or die "Illegal line (array context) in $dir/$file:\n$_\n";
82 or die "Illegal line (scalar context) in $dir/$file:\n$_\n";
89 Returns true if the specified key exists, even if the corresponding value
96 my($dir) = $self->dir;
104 Write access (with locking) should be implemented.
108 config.html from the base documentation contains a list of configuration files.