Changeset 3286


Ignore:
Timestamp:
03/12/09 07:48:28 (3 years ago)
Author:
jquelin
Message:

new method reset_my_plugin()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Padre/lib/Padre/PluginManager.pm

    r3185 r3286  
    2121use strict; 
    2222use warnings; 
     23 
    2324use Carp                     qw{croak}; 
    2425use File::Path               (); 
    2526use File::Spec               (); 
     27use File::Spec::Functions    qw{ catfile }; 
    2628use Scalar::Util             (); 
    2729use Params::Util             qw{_IDENTIFIER _CLASS _INSTANCE}; 
     30use Padre::Config::Constants qw{ $PADRE_PLUGIN_DIR }; 
    2831use Padre::Util              (); 
    2932use Padre::PluginHandle      (); 
     
    133136##################################################################### 
    134137# Bulk Plugin Operations 
     138 
     139# 
     140# $pluginmgr->reset_my_plugin( $overwrite ); 
     141# 
     142# reset the my plugin if needed. if $overwrite is set, remove it first. 
     143# 
     144sub reset_my_plugin { 
     145    my ($self, $overwrite) = @_; 
     146 
     147    # do not overwrite it unless stated so. 
     148    my $dst = catfile( $PADRE_PLUGIN_DIR, 'My.pm' ); 
     149    return if -e $dst && !$overwrite; 
     150     
     151    # find the My Plugin 
     152    my $src = catfile( dirname($INC{'Padre/Config.pm'}), 'Plugin', 'My.pm' ); 
     153    die "Could not find the original My plugin" unless -e $src; 
     154 
     155    # copy the My Plugin 
     156    unlink $dst; 
     157    copy($src, $dst) or die "Could not copy the My plugin ($src) to $dst: $!"; 
     158    chmod( 0644, $dst); 
     159} 
     160 
    135161 
    136162# Disable (but don't unload) all plugins when Padre exits. 
Note: See TracChangeset for help on using the changeset viewer.