Ignore:
Timestamp:
02/08/10 02:23:11 (2 years ago)
Author:
adamk
Message:

Added support for --reset to flush and reset the configuration to defaults, because the Swarm plugin is instantly segfaulting Padre at startup and I didn't want to have to keep resetting the configuration by hand all the time.

File:
1 edited

Legend:

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

    r10436 r10615  
    102102); 
    103103 
    104 use constant LOG_FILE => File::Spec->catfile( CONFIG_DIR, 'debug.log' ); 
    105 use constant PLUGIN_DIR => File::Spec->catdir( CONFIG_DIR, 'plugins' ); 
    106 use constant PLUGIN_LIB => File::Spec->catdir( PLUGIN_DIR, 'Padre', 'Plugin' ); 
     104use constant LOG_FILE       => File::Spec->catfile( CONFIG_DIR, 'debug.log' ); 
     105use constant PLUGIN_DIR     => File::Spec->catdir( CONFIG_DIR, 'plugins' ); 
     106use constant PLUGIN_LIB     => File::Spec->catdir( PLUGIN_DIR, 'Padre', 'Plugin' ); 
    107107use constant CONFIG_HOST    => File::Spec->catfile( CONFIG_DIR, 'config.db' ); 
    108108use constant CONFIG_HUMAN   => File::Spec->catfile( CONFIG_DIR, 'config.yml' ); 
    109109use constant CONFIG_STARTUP => File::Spec->catfile( CONFIG_DIR, 'startup.yml' ); 
    110110 
    111 # Check and create the directories that need to exist 
    112 unless ( -e CONFIG_DIR or File::Path::mkpath(CONFIG_DIR) ) { 
    113     Carp::croak( "Cannot create config directory '" . CONFIG_DIR . "': $!" ); 
     111# Do the initialisation in a function, 
     112# so we can run it again later if needed. 
     113sub init { 
     114    # Check and create the directories that need to exist 
     115    unless ( -e CONFIG_DIR or File::Path::mkpath(CONFIG_DIR) ) { 
     116        Carp::croak( "Cannot create config directory '" . CONFIG_DIR . "': $!" ); 
     117    } 
     118    unless ( -e PLUGIN_LIB or File::Path::mkpath(PLUGIN_LIB) ) { 
     119        Carp::croak( "Cannot create plug-ins directory '" . PLUGIN_LIB . "': $!" ); 
     120    } 
    114121} 
    115 unless ( -e PLUGIN_LIB or File::Path::mkpath(PLUGIN_LIB) ) { 
    116     Carp::croak( "Cannot create plug-ins directory '" . PLUGIN_LIB . "': $!" ); 
     122 
     123BEGIN { 
     124    init(); 
    117125} 
    118126 
     
    132140# NOTE: The only reason this is here is that it is needed both during 
    133141# main configuration, and also during Padre::Startup. 
    134 use constant DEFAULT_SINGLEINSTANCE => ( WIN32 and not( $ENV{HARNESS_ACTIVE} or $^P ) ) ? 1 : 0; 
     142use constant DEFAULT_SINGLEINSTANCE => ( 
     143    WIN32 and not( $ENV{HARNESS_ACTIVE} or $^P ) 
     144) ? 1 : 0; 
    135145 
    136146use constant DEFAULT_SINGLEINSTANCE_PORT => 4444; 
    137  
    138  
    139  
    140  
    141  
    142 ##################################################################### 
    143 # Pseudo Constants 
    144  
    145 my $revision; 
    146  
    147 # Get the svn revision of the currently running Padre once: 
    148 # eval 'use constant PADRE_REVISION => Padre::Util::revision;'; 
    149 # This needs to be a pseudo constant as it requires Padre::Util which 
    150 # requires Padre::Constant (this module). 
    151 sub PADRE_REVISION () { 
    152  
    153     # Get and keep the revision at the first call of this pseudo-constant 
    154     # (usually at Padre start) 
    155     require Padre::Util; 
    156     $revision ||= Padre::Util::revision(); 
    157     return $revision; 
    158 } 
    159147 
    1601481; 
Note: See TracChangeset for help on using the changeset viewer.