]> git.mjollnir.org Git - cil.git/commitdiff
Do checking of the config file in a nicer way.
authorAndrew Chilton <andychilton@gmail.com>
Tue, 1 Jul 2008 03:18:07 +0000 (15:18 +1200)
committerAndrew Chilton <andychilton@gmail.com>
Tue, 1 Jul 2008 03:18:07 +0000 (15:18 +1200)
lib/CIL.pm

index e2be890cfdaa36a1fee0967ff59b64f322c15682..bd01a88f9fbe62179d6f23e369f57aff5ccb6ef9 100644 (file)
@@ -162,7 +162,15 @@ sub get_attachments_for {
 sub read_config_file {
     my ( $self, $filename ) = @_;
 
-    my $cfg = CIL::Utils->parse_cil_file( $filename );
+    # since we might not have a '.cil' file yet (in the case where we're calling 'init',
+    # then we should just return whatever the defaults are
+    my $cfg;
+    if ( -f $filename ) {
+        $cfg = CIL::Utils->parse_cil_file( $filename );
+    }
+    else {
+        $cfg = $defaults;
+    }
 
     # set some defaults if we don't have any of these
     foreach my $key ( keys %$defaults ) {