From ad3ac793135a809a97707e4a4743c755a37306d6 Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Fri, 30 Sep 2005 12:43:20 +0000 Subject: Use meaningful return values for DistribConf::load() --- Distribconf.pm | 17 +++++++---------- dumpdistribconf | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Distribconf.pm b/Distribconf.pm index 0e269ed..8c7735c 100644 --- a/Distribconf.pm +++ b/Distribconf.pm @@ -11,7 +11,7 @@ Distribconf - perl module to get config from a Mandriva Linux distribution tree use Distribconf; my $d = Distribconf->new("/path/to/the/distribution/root"); - $d->load() == 0 + $d->load() or die "This doesn't seem to be a distribution tree\n"; print $d->getpath(undef, "root") ."\n"; @@ -179,22 +179,19 @@ Finds and loads the configuration of the distrib: locate the path where information is found; if available loads F, if available loads F. -Returns 0 on success, 1 if no directory containing media information is found, -2 if no F, neither F files are found. +Returns 1 on success, 0 error (that is, if no directory containing media +information is found, or if no F, neither F files are +found). See also L, L and L. =cut -# TODO return 0 on error like everyone else does - sub load { my ($distrib) = @_; - $distrib->loadtree() or return 1; - - $distrib->parse_mediacfg() || $distrib->parse_hdlists() or return 2; - - return 0; + $distrib->loadtree() or return 0; + $distrib->parse_mediacfg() || $distrib->parse_hdlists() or return 0; + return 1; } =head2 $distrib->loadtree() diff --git a/dumpdistribconf b/dumpdistribconf index 4cf570f..2047072 100755 --- a/dumpdistribconf +++ b/dumpdistribconf @@ -26,7 +26,7 @@ GetOptions( foreach (@ARGV) { print "Using root $_...\n"; my $d = Distribconf::Build->new($_); - $d->load and do { + $d->load or do { warn "Can't load configuration from $_\n"; next; }; -- cgit v1.2.1