Changeset 28213 for main/trunk


Ignore:
Timestamp:
2013-09-04T22:09:17+12:00 (11 years ago)
Author:
ak19
Message:

Clean up. Removed an usused new method to convert a path to its absolute version on this OS, whose equivalent already existed and tidied up the new functions to convert from absolute paths to placeholders and vice-versa.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/util.pm

    r28211 r28213  
    12591259    }
    12601260
    1261     elsif (defined $ENV{'SITEHOME'}) { #&FileUtils::filenameConcatenate(&util::get_site_dir($site),"collect");
     1261    elsif (defined $ENV{'SITEHOME'}) {
    12621262    return &FileUtils::filenameConcatenate($ENV{'SITEHOME'},"collect");
    12631263    }
     
    12671267    }
    12681268}
    1269 
    1270 sub is_abs_path_this_os {
    1271     my ($path) = @_;
    1272 
    1273     # File::Spec loads the module appropriate for the OS
    1274     return &FileUtils::isFilenameAbsolute(@_); #return File::Spec->file_name_is_absolute( $path );
    1275 }
    1276 
    12771269
    12781270sub is_abs_path_any_os {
     
    13051297   
    13061298    # now we know we're dealing with absolute paths and have to replace gs prefixes with placeholders
    1307 
    1308     my $site = $ENV{'SITEHOME'} ? $ENV{'SITEHOME'} : "";
    1309     my @gs_paths = ($ENV{'GSDLCOLLECTDIR'}, $ENV{'GSDLCOLLECTHOME'}, $site, $ENV{'GREENSTONEHOME'}); # list in this order: from longest to shortest path
     1299    my @gs_paths = ($ENV{'GSDLCOLLECTDIR'}, $ENV{'GSDLCOLLECTHOME'}, $ENV{'SITEHOME'}, $ENV{'GREENSTONEHOME'}); # list in this order: from longest to shortest path
    13101300
    13111301    my %placeholder_map = ($ENV{'GREENSTONEHOME'} => '@GSDLHOME@', # can't use double-quotes around at-sign, else perl tries to evaluate it as referring to an array
    1312                $site => '@SITEHOME@',
    13131302               $ENV{'GSDLCOLLECTHOME'} => '@COLLECTHOME@',
    13141303               $ENV{'GSDLCOLLECTDIR'} => '@THISCOLLECTPATH@'
    13151304    );
     1305    $placeholder_map{$ENV{'SITEHOME'}} = '@SITEHOME@' if defined $ENV{'SITEHOME'};
    13161306
    13171307
     
    13211311
    13221312    foreach my $gs_path (@gs_paths) {
    1323     next if($gs_path eq ""); # site can be empty
     1313    next if(!defined $gs_path); # site undefined for GS2
    13241314
    13251315    my $re_path =  &util::filename_to_regex($gs_path); # escape for regex
     
    13451335    return $path if($path !~ m/@/); # path contains no placeholders
    13461336   
    1347     # replace placeholders with gs prefixes
    1348     my $site = $ENV{'SITEHOME'} ? $ENV{'SITEHOME'} : "";
     1337    # replace placeholders with gs prefixes
    13491338    my @placeholders = ('@THISCOLLECTPATH@', '@COLLECTHOME@', '@SITEHOME@', '@GSDLHOME@'); # order of paths not crucial in this case,
    13501339                       # but listed here from longest to shortest once placeholders are have been resolved
    13511340
    1352     my %placeholder_to_gspath_map = ('@GSDLHOME@' => $ENV{'GREENSTONEHOME'}, # can't use double-quotes around at-sign, else perl tries to evaluate it as referring to an array
    1353                '@SITEHOME@' => $site,
    1354                '@COLLECTHOME@' => $ENV{'GSDLCOLLECTHOME'},
    1355                '@THISCOLLECTPATH@' => $ENV{'GSDLCOLLECTDIR'}
    1356     );
    1357 
     1341    # can't use double-quotes around at-sign, else perl tries to evaluate it as referring to an array
     1342    my %placeholder_to_gspath_map = ('@GSDLHOME@' => $ENV{'GREENSTONEHOME'},
     1343                     '@SITEHOME@' => $ENV{'SITEHOME'},
     1344                     '@COLLECTHOME@' => $ENV{'GSDLCOLLECTHOME'},
     1345                     '@THISCOLLECTPATH@' => $ENV{'GSDLCOLLECTDIR'}
     1346    ); # $placeholder_to_gspath_map{'@SITEHOME@'} = $ENV{'SITEHOME'} if defined $ENV{'SITEHOME'};
    13581347
    13591348    foreach my $placeholder (@placeholders) {
    13601349    my $gs_path = $placeholder_to_gspath_map{$placeholder};
    13611350
    1362     next if($gs_path eq ""); # no value for sitehome for GS2
     1351    next if(!defined $gs_path); # sitehome for GS2 is undefined
    13631352
    13641353    #my $sep = ($ENV{'GSDLOS'} eq "windows") ? "\\" : "/";
Note: See TracChangeset for help on using the changeset viewer.