source: perl/lib/BarnOwl/ModuleLoader.pm @ 0337203

barnowl_perlaimdebianrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 0337203 was 0337203, checked in by Nelson Elhage <nelhage@mit.edu>, 17 years ago
First phase of the module rewrite. Internals now (IMO) somewhat cleaner. r19586@phanatique: nelhage | 2007-03-14 20:35:39 -0400 First pass at a cleaned up perlwrap.pm * Using a new hook style * Modules loaded by BarnOwl::ModuleLoader (not yet written) reload is unimplemented for now. If possible, I'd like it to live elsewhere. r19587@phanatique: nelhage | 2007-03-14 20:36:58 -0400 Switching to the new underscore internal hook names. r19592@phanatique: nelhage | 2007-03-16 00:34:00 -0400 Actually switch to _receive_msg r19593@phanatique: nelhage | 2007-03-16 00:34:27 -0400 Some minor cleanup of perlwrap.pm. Shoving fake entries into @INC. r19594@phanatique: nelhage | 2007-03-16 00:34:47 -0400 First revision of ModuleLoader.
  • Property mode set to 100644
File size: 799 bytes
Line 
1use strict;
2use warnings;
3
4package BarnOwl::ModuleLoader;
5
6use lib (BarnOwl::get_data_dir() . "/modules/");
7use PAR (BarnOwl::get_data_dir() . "/modules/*.par");
8use PAR ($ENV{HOME} . "/.owl/modules/*.par");
9
10sub load_all {
11    my %modules;
12    my @modules;
13   
14    for my $dir ( BarnOwl::get_data_dir() . "/modules",
15                  $ENV{HOME} . "/.owl/modules" ) {
16        opendir(my $dh, $dir) or next;
17        @modules = grep /\.par$/, readdir($dh);
18        closedir($dh);
19        for my $mod (@modules) {
20            my ($class) = ($mod =~ /^(.+)\.par$/);
21            $modules{$class} = 1;
22        }
23    }
24    for my $class (keys %modules) {
25        if(defined eval "use BarnOwl::Module::$class") {
26            BarnOwl::error("Unable to load module $class: $@") if $@;
27        }
28    }
29}
30
311;
Note: See TracBrowser for help on using the repository browser.