Changeset 32847

Show
Ignore:
Timestamp:
04.03.2019 13:51:49 (6 months ago)
Author:
kjdon
Message:

reindented in emacs

Files:
1 modified

Legend:

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

    r32845 r32847  
    5151# removes files (but not directories) 
    5252sub rm { 
    53   warnings::warnif("deprecated", "util::rm() is deprecated, using FileUtils::removeFiles() instead"); 
    54   return &FileUtils::removeFiles(@_); 
     53    warnings::warnif("deprecated", "util::rm() is deprecated, using FileUtils::removeFiles() instead"); 
     54    return &FileUtils::removeFiles(@_); 
    5555} 
    5656 
    5757# recursive removal 
    5858sub filtered_rm_r { 
    59   warnings::warnif("deprecated", "util::filtered_rm_r() is deprecated, using FileUtils::removeFilesFiltered() instead"); 
    60   return &FileUtils::removeFilesFiltered(@_); 
     59    warnings::warnif("deprecated", "util::filtered_rm_r() is deprecated, using FileUtils::removeFilesFiltered() instead"); 
     60    return &FileUtils::removeFilesFiltered(@_); 
    6161} 
    6262 
    6363# recursive removal 
    6464sub rm_r { 
    65   warnings::warnif("deprecated", "util::rm_r() is deprecated, using FileUtils::removeFilesRecursive() instead"); 
    66   return &FileUtils::removeFilesRecursive(@_); 
     65    warnings::warnif("deprecated", "util::rm_r() is deprecated, using FileUtils::removeFilesRecursive() instead"); 
     66    return &FileUtils::removeFilesRecursive(@_); 
    6767} 
    6868 
    6969# moves a file or a group of files 
    7070sub mv { 
    71   warnings::warnif("deprecated", "util::mv() is deprecated, using FileUtils::moveFiles() instead"); 
    72   return &FileUtils::moveFiles(@_); 
     71    warnings::warnif("deprecated", "util::mv() is deprecated, using FileUtils::moveFiles() instead"); 
     72    return &FileUtils::moveFiles(@_); 
    7373} 
    7474 
     
    7878# but other files and folders in the target will continue to exist 
    7979sub mv_dir_contents { 
    80   warnings::warnif("deprecated", "util::mv_dir_contents() is deprecated, using FileUtils::moveDirectoryContents() instead"); 
    81   return &FileUtils::moveDirectoryContents(@_); 
     80    warnings::warnif("deprecated", "util::mv_dir_contents() is deprecated, using FileUtils::moveDirectoryContents() instead"); 
     81    return &FileUtils::moveDirectoryContents(@_); 
    8282} 
    8383 
    8484# copies a file or a group of files 
    8585sub cp { 
    86   warnings::warnif("deprecated", "util::cp() is deprecated, using FileUtils::copyFiles() instead"); 
    87   return &FileUtils::copyFiles(@_); 
     86    warnings::warnif("deprecated", "util::cp() is deprecated, using FileUtils::copyFiles() instead"); 
     87    return &FileUtils::copyFiles(@_); 
    8888} 
    8989 
     
    9393# another use cp instead 
    9494sub cp_r { 
    95   warnings::warnif("deprecated", "util::cp_r() is deprecated, using FileUtils::copyFilesrecursive() instead"); 
    96   return &FileUtils::copyFilesRecursive(@_); 
     95    warnings::warnif("deprecated", "util::cp_r() is deprecated, using FileUtils::copyFilesrecursive() instead"); 
     96    return &FileUtils::copyFilesRecursive(@_); 
    9797} 
    9898 
     
    102102# another use cp instead 
    103103sub cp_r_nosvn { 
    104   warnings::warnif("deprecated", "util::cp_r_nosvn() is deprecated, using FileUtils::copyFilesRecursiveNoSVN() instead"); 
    105   return &FileUtils::copyFilesRecursiveNoSVN(@_); 
     104    warnings::warnif("deprecated", "util::cp_r_nosvn() is deprecated, using FileUtils::copyFilesRecursiveNoSVN() instead"); 
     105    return &FileUtils::copyFilesRecursiveNoSVN(@_); 
    106106} 
    107107 
    108108# copies a directory and its contents, excluding subdirectories, into a new directory 
    109109sub cp_r_toplevel { 
    110   warnings::warnif("deprecated", "util::cp_r_toplevel() is deprecated, using FileUtils::recursiveCopyTopLevel() instead"); 
    111   return &FileUtils::recursiveCopyTopLevel(@_); 
     110    warnings::warnif("deprecated", "util::cp_r_toplevel() is deprecated, using FileUtils::recursiveCopyTopLevel() instead"); 
     111    return &FileUtils::recursiveCopyTopLevel(@_); 
    112112} 
    113113 
    114114sub mk_dir { 
    115   warnings::warnif("deprecated", "util::mk_dir() is deprecated, using FileUtils::makeDirectory() instead"); 
    116   return &FileUtils::makeDirectory(@_); 
     115    warnings::warnif("deprecated", "util::mk_dir() is deprecated, using FileUtils::makeDirectory() instead"); 
     116    return &FileUtils::makeDirectory(@_); 
    117117} 
    118118 
     
    121121# slightly faster (surprisingly) - Stefan. 
    122122sub mk_all_dir { 
    123   warnings::warnif("deprecated", "util::mk_all_dir() is deprecated, using FileUtils::makeAllDirectories() instead"); 
    124   return &FileUtils::makeAllDirectories(@_); 
     123    warnings::warnif("deprecated", "util::mk_all_dir() is deprecated, using FileUtils::makeAllDirectories() instead"); 
     124    return &FileUtils::makeAllDirectories(@_); 
    125125} 
    126126 
    127127# make hard link to file if supported by OS, otherwise copy the file 
    128128sub hard_link { 
    129   warnings::warnif("deprecated", "util::hard_link() is deprecated, using FileUtils::hardLink() instead"); 
    130   return &FileUtils::hardLink(@_); 
     129    warnings::warnif("deprecated", "util::hard_link() is deprecated, using FileUtils::hardLink() instead"); 
     130    return &FileUtils::hardLink(@_); 
    131131} 
    132132 
    133133# make soft link to file if supported by OS, otherwise copy file 
    134134sub soft_link { 
    135   warnings::warnif("deprecated", "util::soft_link() is deprecated, using FileUtils::softLink() instead"); 
    136   return &FileUtils::softLink(@_); 
     135    warnings::warnif("deprecated", "util::soft_link() is deprecated, using FileUtils::softLink() instead"); 
     136    return &FileUtils::softLink(@_); 
    137137} 
    138138 
     
    167167sub raw_filename_to_unicode 
    168168{ 
    169     my ($directory, $raw_file, $filename_encoding ) = @_; 
    170          
    171     my $unicode_filename = $raw_file; 
    172     if (($ENV{'GSDLOS'} =~ m/^windows$/i) && ($^O ne "cygwin")) { 
    173         # Try turning a short version to the long version 
    174         # If there are "funny" characters in the file name, that can't be represented in the ANSI code, then we will have a short weird version, eg E74~1.txt 
    175         $unicode_filename = &util::get_dirsep_tail(&util::upgrade_if_dos_filename(&FileUtils::filenameConcatenate($directory, $raw_file), 0)); 
     169    my ($directory, $raw_file, $filename_encoding ) = @_; 
     170     
     171    my $unicode_filename = $raw_file; 
     172    if (($ENV{'GSDLOS'} =~ m/^windows$/i) && ($^O ne "cygwin")) { 
     173    # Try turning a short version to the long version 
     174    # If there are "funny" characters in the file name, that can't be represented in the ANSI code, then we will have a short weird version, eg E74~1.txt 
     175    $unicode_filename = &util::get_dirsep_tail(&util::upgrade_if_dos_filename(&FileUtils::filenameConcatenate($directory, $raw_file), 0)); 
     176     
     177     
     178    if ($unicode_filename eq $raw_file) { 
     179        # This means the original filename *was* able to be encoded in the local ANSI file encoding (eg windows_1252), so now we turn it back to perl's unicode 
    176180         
    177          
    178         if ($unicode_filename eq $raw_file) { 
    179         # This means the original filename *was* able to be encoded in the local ANSI file encoding (eg windows_1252), so now we turn it back to perl's unicode 
    180          
    181         $unicode_filename = &Encode::decode(locale_fs => $unicode_filename); 
    182         } 
    183         # else This means we did have one of the funny filenames. the getLongPathName (used in upgrade_if_dos_filename) will return unicode, so we don't need to do anything more. 
    184          
    185                      
    186     } else { 
    187         # we had a utf-8 string, turn it into perl internal unicode 
    188         $unicode_filename = &Encode::decode("utf-8", $unicode_filename); 
    189      
    190          
    191     } 
    192     #Does the filename have url encoded chars in it? 
    193     if (&unicode::is_url_encoded($unicode_filename)) { 
    194         $unicode_filename = &unicode::url_decode($unicode_filename); 
    195     } 
    196      
    197     # Normalise the filename to canonical composition - on mac, filenames use decopmposed form for accented chars 
    198     if ($ENV{'GSDLOS'} =~ m/^darwin$/i) { 
    199         $unicode_filename = normalize('C', $unicode_filename); # Composed form 'C' 
    200     } 
    201     return $unicode_filename; 
     181        $unicode_filename = &Encode::decode(locale_fs => $unicode_filename); 
     182    } 
     183    # else This means we did have one of the funny filenames. the getLongPathName (used in upgrade_if_dos_filename) will return unicode, so we don't need to do anything more. 
     184     
     185     
     186    } else { 
     187    # we had a utf-8 string, turn it into perl internal unicode 
     188    $unicode_filename = &Encode::decode("utf-8", $unicode_filename); 
     189     
     190     
     191    } 
     192    #Does the filename have url encoded chars in it? 
     193    if (&unicode::is_url_encoded($unicode_filename)) { 
     194    $unicode_filename = &unicode::url_decode($unicode_filename); 
     195    } 
     196     
     197    # Normalise the filename to canonical composition - on mac, filenames use decopmposed form for accented chars 
     198    if ($ENV{'GSDLOS'} =~ m/^darwin$/i) { 
     199    $unicode_filename = normalize('C', $unicode_filename); # Composed form 'C' 
     200    } 
     201    return $unicode_filename; 
    202202 
    203203} 
    204204sub fd_exists { 
    205   warnings::warnif("deprecated", "util::fd_exists() is deprecated, using FileUtils::fileTest() instead"); 
    206   return &FileUtils::fileTest(@_); 
     205    warnings::warnif("deprecated", "util::fd_exists() is deprecated, using FileUtils::fileTest() instead"); 
     206    return &FileUtils::fileTest(@_); 
    207207} 
    208208 
    209209sub file_exists { 
    210   warnings::warnif("deprecated", "util::file_exists() is deprecated, using FileUtils::fileExists() instead"); 
    211   return &FileUtils::fileExists(@_); 
     210    warnings::warnif("deprecated", "util::file_exists() is deprecated, using FileUtils::fileExists() instead"); 
     211    return &FileUtils::fileExists(@_); 
    212212} 
    213213 
    214214sub dir_exists { 
    215   warnings::warnif("deprecated", "util::dir_exists() is deprecated, using FileUtils::directoryExists() instead"); 
    216   return &FileUtils::directoryExists(@_); 
     215    warnings::warnif("deprecated", "util::dir_exists() is deprecated, using FileUtils::directoryExists() instead"); 
     216    return &FileUtils::directoryExists(@_); 
    217217} 
    218218 
     
    221221# both $fromdir and $todir should be absolute paths 
    222222sub cachedir { 
    223   warnings::warnif("deprecated", "util::cachedir() is deprecated, using FileUtils::synchronizeDirectories() instead"); 
    224   return &FileUtils::synchronizeDirectories(@_); 
     223    warnings::warnif("deprecated", "util::cachedir() is deprecated, using FileUtils::synchronizeDirectories() instead"); 
     224    return &FileUtils::synchronizeDirectories(@_); 
    225225} 
    226226 
     
    230230# $file2 is allowed to be newer than $file1 
    231231sub differentfiles { 
    232   warnings::warnif("deprecated", "util::differentfiles() is deprecated, using FileUtils::differentFiles() instead"); 
    233   return &FileUtils::differentFiles(@_); 
     232    warnings::warnif("deprecated", "util::differentfiles() is deprecated, using FileUtils::differentFiles() instead"); 
     233    return &FileUtils::differentFiles(@_); 
    234234} 
    235235 
     
    239239sub determine_tmp_dir 
    240240{ 
    241     my $try_collect_dir = shift(@_) || 0; 
    242  
    243     my $tmp_dirname; 
    244     if(defined $ENV{'GS_TMP_OUTPUT_DIR'}) { 
    245         $tmp_dirname = $ENV{'GS_TMP_OUTPUT_DIR'}; 
    246     } elsif($try_collect_dir && defined $ENV{'GSDLCOLLECTDIR'}) { 
    247         $tmp_dirname = $ENV{'GSDLCOLLECTDIR'}; 
     241    my $try_collect_dir = shift(@_) || 0; 
     242 
     243    my $tmp_dirname; 
     244    if(defined $ENV{'GS_TMP_OUTPUT_DIR'}) { 
     245    $tmp_dirname = $ENV{'GS_TMP_OUTPUT_DIR'}; 
     246    } elsif($try_collect_dir && defined $ENV{'GSDLCOLLECTDIR'}) { 
     247    $tmp_dirname = $ENV{'GSDLCOLLECTDIR'}; 
    248248    } elsif(defined $ENV{'GSDLHOME'}) { 
    249         $tmp_dirname = $ENV{'GSDLHOME'}; 
     249    $tmp_dirname = $ENV{'GSDLHOME'}; 
    250250    } else { 
    251         return undef; 
    252     } 
    253      
    254     if(!defined $ENV{'GS_TMP_OUTPUT_DIR'}) { 
    255         # test the tmp_dirname folder is writable, by trying to write out a file 
    256         # Unfortunately, cound not get if(-w $dirname) to work on directories on Windows 
    257             ## http://alvinalexander.com/blog/post/perl/perl-file-test-operators-reference-cheat-sheet (test file/dir writable) 
    258             ## http://www.makelinux.net/alp/083 (real and effective user IDs) 
    259          
    260         my $tmp_test_file = &FileUtils::filenameConcatenate($tmp_dirname, "writability_test.tmp"); 
    261         if (open (FOUT, ">$tmp_test_file")) { 
    262             close(FOUT); 
    263             &FileUtils::removeFiles($tmp_test_file); 
    264         } else { # location not writable, use TMP location 
    265         if (defined $ENV{'TMP'}) { 
    266             $tmp_dirname = $ENV{'TMP'}; 
    267         } else { 
    268             $tmp_dirname = "/tmp"; 
    269         } 
    270         $tmp_dirname = &FileUtils::filenameConcatenate($tmp_dirname, "greenstone"); 
    271             $ENV{'GS_TMP_OUTPUT_DIR'} = $tmp_dirname; # store for next time 
    272         } 
    273     } 
    274      
    275     $tmp_dirname = &FileUtils::filenameConcatenate($tmp_dirname, "tmp"); 
    276     &FileUtils::makeAllDirectories ($tmp_dirname) unless -e $tmp_dirname; 
    277  
    278     return $tmp_dirname; 
     251    return undef; 
     252    } 
     253     
     254    if(!defined $ENV{'GS_TMP_OUTPUT_DIR'}) { 
     255    # test the tmp_dirname folder is writable, by trying to write out a file 
     256    # Unfortunately, cound not get if(-w $dirname) to work on directories on Windows 
     257    ## http://alvinalexander.com/blog/post/perl/perl-file-test-operators-reference-cheat-sheet (test file/dir writable) 
     258    ## http://www.makelinux.net/alp/083 (real and effective user IDs) 
     259     
     260    my $tmp_test_file = &FileUtils::filenameConcatenate($tmp_dirname, "writability_test.tmp"); 
     261    if (open (FOUT, ">$tmp_test_file")) { 
     262        close(FOUT); 
     263        &FileUtils::removeFiles($tmp_test_file); 
     264    } else { # location not writable, use TMP location 
     265        if (defined $ENV{'TMP'}) { 
     266        $tmp_dirname = $ENV{'TMP'}; 
     267        } else { 
     268        $tmp_dirname = "/tmp"; 
     269        } 
     270        $tmp_dirname = &FileUtils::filenameConcatenate($tmp_dirname, "greenstone"); 
     271        $ENV{'GS_TMP_OUTPUT_DIR'} = $tmp_dirname; # store for next time 
     272    } 
     273    } 
     274     
     275    $tmp_dirname = &FileUtils::filenameConcatenate($tmp_dirname, "tmp"); 
     276    &FileUtils::makeAllDirectories ($tmp_dirname) unless -e $tmp_dirname; 
     277 
     278    return $tmp_dirname; 
    279279} 
    280280 
     
    296296    } 
    297297 
    298     my $tmpdir = &util::determine_tmp_dir(0); 
     298    my $tmpdir = &util::determine_tmp_dir(0); 
    299299 
    300300    my $count = 1000; 
     
    318318sub get_timestamped_tmp_folder 
    319319{ 
    320     my $tmp_dirname = &util::determine_tmp_dir(1); 
    321      
     320    my $tmp_dirname = &util::determine_tmp_dir(1); 
     321     
    322322    # add the timestamp into the path otherwise we can run into problems  
    323323    # if documents have the same name 
    324324    my $timestamp = time;    
    325      
    326     if (!defined $previous_timestamp || ($timestamp > $previous_timestamp)) { 
    327         $previous_timestamp_f = 0; 
    328         $previous_timestamp = $timestamp; 
    329     } else { 
    330         $previous_timestamp_f++; 
    331     }  
    332      
     325     
     326    if (!defined $previous_timestamp || ($timestamp > $previous_timestamp)) { 
     327    $previous_timestamp_f = 0; 
     328    $previous_timestamp = $timestamp; 
     329    } else { 
     330    $previous_timestamp_f++; 
     331    }  
     332     
    333333    my $time_tmp_dirname = &FileUtils::filenameConcatenate($tmp_dirname, $timestamp); 
    334334    $tmp_dirname = $time_tmp_dirname;    
    335335    my $i = $previous_timestamp_f; 
    336      
    337     if($previous_timestamp_f > 0) { 
    338         $tmp_dirname = $time_tmp_dirname."_".$i; 
    339         $i++; 
    340     } 
     336     
     337    if($previous_timestamp_f > 0) { 
     338    $tmp_dirname = $time_tmp_dirname."_".$i; 
     339    $i++; 
     340    } 
    341341    while (-e $tmp_dirname) { 
    342342    $tmp_dirname = $time_tmp_dirname."_".$i; 
     
    408408    # need to make single backslashes double so that regex works 
    409409    $filename =~ s/\\/\\\\/g; # if ($ENV{'GSDLOS'} =~ /^windows$/i);     
    410      
     410     
    411411    # note that the first part of a substitution is a regex, so RE chars need to be escaped, 
    412412    # the second part of a substitution is not a regex, so for e.g. full-stop can be specified literally 
    413     $filename =~ s/\./\\./g; # in case there are extensions/other full stops, escape them 
    414     $filename =~ s@\(@\\(@g; # escape brackets 
    415     $filename =~ s@\)@\\)@g; # escape brackets 
    416     $filename =~ s@\[@\\[@g; # escape brackets 
    417     $filename =~ s@\]@\\]@g; # escape brackets 
    418      
     413    $filename =~ s/\./\\./g; # in case there are extensions/other full stops, escape them 
     414    $filename =~ s@\(@\\(@g; # escape brackets 
     415    $filename =~ s@\)@\\)@g; # escape brackets 
     416    $filename =~ s@\[@\\[@g; # escape brackets 
     417    $filename =~ s@\]@\\]@g; # escape brackets 
     418     
    419419    return $filename; 
    420420} 
     
    424424 
    425425    # need to put doubled backslashes for regex back to single 
    426     $filename =~ s/\\\./\./g; # remove RE syntax for . 
    427     $filename =~ s@\\\(@(@g; # remove RE syntax for ( => "\(" turns into "(" 
    428     $filename =~ s@\\\)@)@g; # remove RE syntax for ) => "\)" turns into ")" 
    429     $filename =~ s@\\\[@[@g; # remove RE syntax for [ => "\[" turns into "[" 
    430     $filename =~ s@\\\]@]@g; # remove RE syntax for ] => "\]" turns into "]" 
    431      
    432     # \\ goes to \ 
    433     # This is the last step in reverse mirroring the order of steps in filename_to_regex() 
    434     $filename =~ s/\\\\/\\/g; # remove RE syntax for \     
     426    $filename =~ s/\\\./\./g; # remove RE syntax for . 
     427    $filename =~ s@\\\(@(@g; # remove RE syntax for ( => "\(" turns into "(" 
     428    $filename =~ s@\\\)@)@g; # remove RE syntax for ) => "\)" turns into ")" 
     429    $filename =~ s@\\\[@[@g; # remove RE syntax for [ => "\[" turns into "[" 
     430    $filename =~ s@\\\]@]@g; # remove RE syntax for ] => "\]" turns into "]" 
     431     
     432    # \\ goes to \ 
     433    # This is the last step in reverse mirroring the order of steps in filename_to_regex() 
     434    $filename =~ s/\\\\/\\/g; # remove RE syntax for \     
    435435    return $filename; 
    436436} 
    437437 
    438438sub filename_cat { 
    439   # I've disabled this warning for now, as every Greenstone perl 
    440   # script seems to make use of this function and so you drown in a 
    441   # sea of deprecated warnings [jmt12] 
    442 #  warnings::warnif("deprecated", "util::filename_cat() is deprecated, using FileUtils::filenameConcatenate() instead"); 
    443   return &FileUtils::filenameConcatenate(@_); 
     439    # I've disabled this warning for now, as every Greenstone perl 
     440    # script seems to make use of this function and so you drown in a 
     441    # sea of deprecated warnings [jmt12] 
     442    #  warnings::warnif("deprecated", "util::filename_cat() is deprecated, using FileUtils::filenameConcatenate() instead"); 
     443    return &FileUtils::filenameConcatenate(@_); 
    444444} 
    445445 
     
    547547 
    548548    # 64 bit linux can't handle ";" as path separator, so make sure to set this to the right one for the OS 
    549 ##    my $pathsep = (defined $ENV{'GSDLOS'} && $ENV{'GSDLOS'} !~ m/windows/) ? ":" : ";"; 
     549    ##    my $pathsep = (defined $ENV{'GSDLOS'} && $ENV{'GSDLOS'} !~ m/windows/) ? ":" : ";"; 
    550550 
    551551    # Rewritten above to make ":" the default (Windows is the special 
     
    632632    my ($base_dir, $file) = @_; 
    633633     
    634 #    my ($cpackage,$cfilename,$cline,$csubr,$chas_args,$cwantarray) = caller(0); 
    635 #    my ($lcfilename) = ($cfilename =~ m/([^\\\/]*)$/); 
    636 #    print STDERR "** Calling method: $lcfilename:$cline $cpackage->$csubr\n"; 
     634    #    my ($cpackage,$cfilename,$cline,$csubr,$chas_args,$cwantarray) = caller(0); 
     635    #    my ($lcfilename) = ($cfilename =~ m/([^\\\/]*)$/); 
     636    #    print STDERR "** Calling method: $lcfilename:$cline $cpackage->$csubr\n"; 
    637637 
    638638 
     
    727727    $within_dir .= $dirsep; 
    728728    } 
    729      
    730     $within_dir = &filename_to_regex($within_dir); # escape DOS style file separator and brackets    
     729     
     730    $within_dir = &filename_to_regex($within_dir); # escape DOS style file separator and brackets    
    731731    if ($filename =~ m/^$within_dir(.*)$/) { 
    732732    $filename = $1; 
     
    742742{ 
    743743    my ($filename,$within_dir) = @_; 
    744      
    745     # convert parameters only to / slashes if Windows 
    746      
    747     my $filename_urlformat = &filepath_to_url_format($filename); 
    748     my $within_dir_urlformat = &filepath_to_url_format($within_dir); 
    749  
    750     #if ($within_dir_urlformat !~ m/\/$/) { 
    751         # make sure directory ends with a slash 
    752         #$within_dir_urlformat .= "/"; 
     744     
     745    # convert parameters only to / slashes if Windows 
     746     
     747    my $filename_urlformat = &filepath_to_url_format($filename); 
     748    my $within_dir_urlformat = &filepath_to_url_format($within_dir); 
     749 
     750    #if ($within_dir_urlformat !~ m/\/$/) { 
     751    # make sure directory ends with a slash 
     752    #$within_dir_urlformat .= "/"; 
    753753    #} 
    754      
    755     my $within_dir_urlformat_re = &filename_to_regex($within_dir_urlformat); # escape any special RE characters, such as brackets 
    756      
    757     #print STDERR "@@@@@ $filename_urlformat =~ $within_dir_urlformat_re\n"; 
    758      
    759     # dir prefix may or may not end with a slash (this is discarded when extracting the sub-filepath) 
     754     
     755    my $within_dir_urlformat_re = &filename_to_regex($within_dir_urlformat); # escape any special RE characters, such as brackets 
     756     
     757    #print STDERR "@@@@@ $filename_urlformat =~ $within_dir_urlformat_re\n"; 
     758     
     759    # dir prefix may or may not end with a slash (this is discarded when extracting the sub-filepath) 
    760760    if ($filename_urlformat =~ m/^$within_dir_urlformat_re(?:\/)*(.*)$/) { 
    761         $filename_urlformat = $1; 
     761    $filename_urlformat = $1; 
    762762    } 
    763763     
     
    769769sub filepath_to_url_format 
    770770{ 
    771     my ($filepath) = @_; 
    772     if (($ENV{'GSDLOS'} =~ /^windows$/i) && ($^O ne "cygwin")) { 
    773         # Only need to worry about Windows, as Unix style directories already in url-format 
    774         # Convert Windows style \ => / 
    775         $filepath =~ s@\\@/@g;       
    776     } 
    777     return $filepath; 
     771    my ($filepath) = @_; 
     772    if (($ENV{'GSDLOS'} =~ /^windows$/i) && ($^O ne "cygwin")) { 
     773    # Only need to worry about Windows, as Unix style directories already in url-format 
     774    # Convert Windows style \ => / 
     775    $filepath =~ s@\\@/@g;       
     776    } 
     777    return $filepath; 
    778778} 
    779779 
     
    804804    my ($dirs, $file) = $filepath =~ m@(.+/)([^/]+)@; 
    805805    return ($file, $dirs); 
    806      
     806     
    807807} 
    808808 
     
    866866     
    867867    if (-e $filename_full_path) { 
    868        my $long_filename = Win32::GetLongPathName($filename_full_path); 
    869        if (defined $long_filename) { 
     868        my $long_filename = Win32::GetLongPathName($filename_full_path); 
     869        if (defined $long_filename) { 
    870870         
    871         $filename_full_path = $long_filename; 
    872     } 
     871        $filename_full_path = $long_filename; 
     872        } 
    873873    } else { 
    874       
    875        my ($tailname, $dirname, $suffix) 
    876             = &File::Basename::fileparse($filename_full_path, "\\.[^\\.]+\$"); 
    877         my $long_dirname = Win32::GetLongPathName($dirname); 
    878         if (defined $long_dirname) { 
     874         
     875        my ($tailname, $dirname, $suffix) 
     876        = &File::Basename::fileparse($filename_full_path, "\\.[^\\.]+\$"); 
     877        my $long_dirname = Win32::GetLongPathName($dirname); 
     878        if (defined $long_dirname) { 
    879879        $filename_full_path = &FileUtils::filenameConcatenate($long_dirname, "$tailname$suffix"); 
    880         } 
     880        } 
    881881    } 
    882882     
     
    901901    # Ensure the given long Windows filename is in a form that can 
    902902    # be opened by Perl => convert it to a short DOS-like filename 
    903     # GetShortPathName doesn't work if the file doesn't exist - in this case, use the directory instead 
    904         if (-e $filename_full_path) { 
    905     my $short_filename = Win32::GetShortPathName($filename_full_path); 
    906     if (defined $short_filename) { 
    907         $filename_full_path = $short_filename; 
    908     } 
     903    # GetShortPathName doesn't work if the file doesn't exist - in this case, use the directory instead 
     904    if (-e $filename_full_path) { 
     905        my $short_filename = Win32::GetShortPathName($filename_full_path); 
     906        if (defined $short_filename) { 
     907        $filename_full_path = $short_filename; 
     908        } 
    909909    } else { 
    910       my ($tailname, $dirname, $suffix) 
    911             = &File::Basename::fileparse($filename_full_path, "\\.[^\\.]+\$"); 
    912         my $short_dirname = Win32::GetShortPathName($dirname); 
    913         if (defined $short_dirname) { 
     910        my ($tailname, $dirname, $suffix) 
     911        = &File::Basename::fileparse($filename_full_path, "\\.[^\\.]+\$"); 
     912        my $short_dirname = Win32::GetShortPathName($dirname); 
     913        if (defined $short_dirname) { 
    914914        $filename_full_path = &FileUtils::filenameConcatenate($short_dirname, "$tailname$suffix"); 
    915         } 
    916      
     915        } 
     916         
    917917    } 
    918918    # Make sure initial drive letter is lower-case (to fit in 
     
    927927sub filename_is_absolute 
    928928{ 
    929   warnings::warnif("deprecated", "util::filename_is_absolute() is deprecated, using FileUtils::isFilenameAbsolute() instead"); 
    930   return &FileUtils::isFilenameAbsolute(@_); 
     929    warnings::warnif("deprecated", "util::filename_is_absolute() is deprecated, using FileUtils::isFilenameAbsolute() instead"); 
     930    return &FileUtils::isFilenameAbsolute(@_); 
    931931} 
    932932 
     
    950950     
    951951    my ($base_dir, $dir) = @_; 
    952 ###    print STDERR "dir = $dir\n"; 
     952    ###    print STDERR "dir = $dir\n"; 
    953953    $dir =~ s/[\\\/]+/\//g; 
    954954    $dir = $base_dir . "/$dir" unless ($dir =~ m|^(\w:)?/|);  
     
    957957    $dir =~ s|/[.][.]?/|/|g; 
    958958    $dir =~ tr|/|/|s; 
    959 ###    print STDERR "dir = $dir\n"; 
     959    ###    print STDERR "dir = $dir\n"; 
    960960     
    961961    return $dir; 
     
    10391039 
    10401040    if (!defined $ENV{'GREENSTONEHOME'}) { # for GS3, would have been defined in use_site_collection, to GSDL3HOME 
    1041      $ENV{'GREENSTONEHOME'} = $ENV{'GSDLHOME'};  
     1041    $ENV{'GREENSTONEHOME'} = $ENV{'GSDLHOME'};  
    10421042    } 
    10431043 
     
    11631163# Code is from http://episteme.arstechnica.com/eve/forums/a/tpc/f/6330927813/m/436007700831 
    11641164sub is_dir_empty { 
    1165   warnings::warnif("deprecated", "util::is_dir_empty() is deprecated, using FileUtils::isDirectoryEmpty() instead"); 
    1166   return &FileUtils::isDirectoryEmpty(@_); 
     1165    warnings::warnif("deprecated", "util::is_dir_empty() is deprecated, using FileUtils::isDirectoryEmpty() instead"); 
     1166    return &FileUtils::isDirectoryEmpty(@_); 
    11671167} 
    11681168 
     
    12061206    # Not sure why it was done in first place... 
    12071207    #else { 
    1208     #$suffix = lc($suffix); 
     1208    #$suffix = lc($suffix); 
    12091209    #} 
    12101210 
     
    13041304    # set for the future 
    13051305    $ENV{'GREENSTONE_URL_PREFIX'} = $urlprefix; 
    1306 #    print STDERR "*** in get_greenstone_url_prefix(): $urlprefix\n\n"; 
     1306    #    print STDERR "*** in get_greenstone_url_prefix(): $urlprefix\n\n"; 
    13071307    return $urlprefix; 
    13081308} 
     
    13221322sub get_full_greenstone_url_prefix 
    13231323{    
    1324     my ($gs_mode, $lib_name, $get_public_url) = @_; 
    1325      
     1324    my ($gs_mode, $lib_name, $get_public_url) = @_; 
     1325     
    13261326    # if already set on a previous occasion, just return that 
    13271327    # (Don't want to keep repeating this: cost of re-opening and scanning files.) 
    13281328    return $ENV{'FULL_GREENSTONE_URL_PREFIX'} if($ENV{'FULL_GREENSTONE_URL_PREFIX'}); 
    13291329 
    1330     # set gs_mode if it was not passed in (servercontrol.pm would pass it in, any other callers won't) 
     1330    # set gs_mode if it was not passed in (servercontrol.pm would pass it in, any other callers won't) 
    13311331    $gs_mode = ($ENV{'GSDL3SRCHOME'}) ? "gs3" : "gs2" unless defined $gs_mode; 
    1332      
     1332     
    13331333    my $url = undef;     
    13341334     
     
    14291429        } 
    14301430        close(PIN); 
    1431          
     1431         
    14321432        # url can be undef if tomcat.port could not be determined due to 
    14331433        # user having wrong or conflicting server related vals in build.props 
    1434            if (defined $url && defined $lib_name && $lib_name ne "") { 
    1435             # replace the servlet_name portion of the url found, with the given library_name 
    1436             $url =~ s@/[^/]*$@/$lib_name@; 
    1437         } 
     1434        if (defined $url && defined $lib_name && $lib_name ne "") { 
     1435        # replace the servlet_name portion of the url found, with the given library_name 
     1436        $url =~ s@/[^/]*$@/$lib_name@; 
     1437        } 
    14381438    } else { 
    14391439        print STDERR "util::get_full_greenstone_url_prefix() failed to run $perl_command to work out library URL for $gs_mode\n"; 
     
    14921492# 
    14931493sub setup_greenstone_env() { 
    1494     my ($GSDLHOME, $GSDLOS) = @_; 
    1495  
    1496     #my %env_map = (); 
    1497     # Get the localised ENV settings of running a localised source setup.bash  
    1498     # and put it into the ENV here. Need to clear GSDLHOME before running setup 
    1499     #my $perl_command = "(cd $GSDLHOME; export GSDLHOME=; . ./setup.bash > /dev/null; env)"; 
    1500     my $perl_command = "(cd $GSDLHOME; /bin/bash -c \"export GSDLHOME=; source setup.bash > /dev/null; env\")";      
    1501     if (($GSDLOS =~ m/windows/i) && ($^O ne "cygwin"))  { 
    1502         #$perl_command = "cmd /C \"cd $GSDLHOME&& set GSDLHOME=&& setup.bat > nul&& set\""; 
    1503         $perl_command = "(cd $GSDLHOME&& set GSDLHOME=&& setup.bat > nul&& set)"; 
    1504     } 
    1505     if (!open(PIN, "$perl_command |")) { 
    1506         print STDERR ("Unable to execute command: $perl_command. $!\n"); 
    1507     } 
    1508  
    1509     my $lastkey; 
    1510     while (defined (my $perl_output_line = <PIN>)) { 
    1511         my($key,$value) = ($perl_output_line =~ m/^([^=]*)[=](.*)$/); 
    1512         if(defined $key) { 
    1513             #$env_map{$key}=$value;      
    1514             $ENV{$key}=$value; 
    1515             $lastkey = $key; 
    1516         } elsif($lastkey && $perl_output_line !~ m/^\s*$/) {  
    1517             # there was no equals sign in $perl_output_line, so this  
    1518             # $perl_output_line may be a spillover from the previous 
    1519             $ENV{$lastkey} = $ENV{$lastkey}."\n".$perl_output_line; 
    1520         } 
    1521     } 
    1522     close (PIN); 
    1523  
    1524     # If any keys in $ENV don't occur in Greenstone's localised env  
    1525     # (stored in $env_map), delete those entries from $ENV 
    1526     #foreach $key (keys %ENV) {  
    1527     #   if(!defined $env_map{$key}) {  
    1528     #       print STDOUT "**** DELETING ENV KEY: $key\tVALUE: $ENV{$key}\n"; 
    1529     #       delete $ENV{$key}; # del $ENV(key, value) pair 
    1530     #   } 
    1531     #} 
    1532     #undef %env_map; 
     1494    my ($GSDLHOME, $GSDLOS) = @_; 
     1495 
     1496    #my %env_map = (); 
     1497    # Get the localised ENV settings of running a localised source setup.bash  
     1498    # and put it into the ENV here. Need to clear GSDLHOME before running setup 
     1499    #my $perl_command = "(cd $GSDLHOME; export GSDLHOME=; . ./setup.bash > /dev/null; env)"; 
     1500    my $perl_command = "(cd $GSDLHOME; /bin/bash -c \"export GSDLHOME=; source setup.bash > /dev/null; env\")";      
     1501    if (($GSDLOS =~ m/windows/i) && ($^O ne "cygwin"))  { 
     1502    #$perl_command = "cmd /C \"cd $GSDLHOME&& set GSDLHOME=&& setup.bat > nul&& set\""; 
     1503    $perl_command = "(cd $GSDLHOME&& set GSDLHOME=&& setup.bat > nul&& set)"; 
     1504    } 
     1505    if (!open(PIN, "$perl_command |")) { 
     1506    print STDERR ("Unable to execute command: $perl_command. $!\n"); 
     1507    } 
     1508 
     1509    my $lastkey; 
     1510    while (defined (my $perl_output_line = <PIN>)) { 
     1511    my($key,$value) = ($perl_output_line =~ m/^([^=]*)[=](.*)$/); 
     1512    if(defined $key) { 
     1513        #$env_map{$key}=$value;      
     1514        $ENV{$key}=$value; 
     1515        $lastkey = $key; 
     1516    } elsif($lastkey && $perl_output_line !~ m/^\s*$/) {  
     1517        # there was no equals sign in $perl_output_line, so this  
     1518        # $perl_output_line may be a spillover from the previous 
     1519        $ENV{$lastkey} = $ENV{$lastkey}."\n".$perl_output_line; 
     1520    } 
     1521    } 
     1522    close (PIN); 
     1523 
     1524    # If any keys in $ENV don't occur in Greenstone's localised env  
     1525    # (stored in $env_map), delete those entries from $ENV 
     1526    #foreach $key (keys %ENV) {  
     1527    #   if(!defined $env_map{$key}) {  
     1528    #       print STDOUT "**** DELETING ENV KEY: $key\tVALUE: $ENV{$key}\n"; 
     1529    #       delete $ENV{$key}; # del $ENV(key, value) pair 
     1530    #   } 
     1531    #} 
     1532    #undef %env_map; 
    15331533} 
    15341534 
    15351535sub get_perl_exec() {    
    1536     my $perl_exec = $^X; # may return just "perl" 
    1537      
    1538     if($ENV{'PERLPATH'}) { 
    1539         # OR: # $perl_exec = &FileUtils::filenameConcatenate($ENV{'PERLPATH'},"perl"); 
    1540         if (($ENV{'GSDLOS'} =~ m/windows/) && ($^O ne "cygwin")) { 
    1541             $perl_exec = "$ENV{'PERLPATH'}\\Perl.exe"; 
    1542         } else { 
    1543             $perl_exec = "$ENV{'PERLPATH'}/perl"; 
    1544         } 
    1545     } else { # no PERLPATH, use Config{perlpath} else $^X: special variables 
    1546         # containing the full path to the current perl executable we're using 
    1547         $perl_exec = $Config{perlpath}; # configured path for perl 
    1548         if (!-e $perl_exec) { # may not point to location on this machine 
    1549             $perl_exec = $^X; # may return just "perl" 
    1550             if($perl_exec =~ m/^perl/i) { # warn if just perl or Perl.exe 
    1551                 print STDERR "**** WARNING: Perl exec found contains no path: $perl_exec";               
    1552             } 
    1553         } 
    1554     } 
    1555      
    1556     return $perl_exec; 
     1536    my $perl_exec = $^X; # may return just "perl" 
     1537     
     1538    if($ENV{'PERLPATH'}) { 
     1539    # OR: # $perl_exec = &FileUtils::filenameConcatenate($ENV{'PERLPATH'},"perl"); 
     1540    if (($ENV{'GSDLOS'} =~ m/windows/) && ($^O ne "cygwin")) { 
     1541        $perl_exec = "$ENV{'PERLPATH'}\\Perl.exe"; 
     1542    } else { 
     1543        $perl_exec = "$ENV{'PERLPATH'}/perl"; 
     1544    } 
     1545    } else { # no PERLPATH, use Config{perlpath} else $^X: special variables 
     1546    # containing the full path to the current perl executable we're using 
     1547    $perl_exec = $Config{perlpath}; # configured path for perl 
     1548    if (!-e $perl_exec) { # may not point to location on this machine 
     1549        $perl_exec = $^X; # may return just "perl" 
     1550        if($perl_exec =~ m/^perl/i) { # warn if just perl or Perl.exe 
     1551        print STDERR "**** WARNING: Perl exec found contains no path: $perl_exec";               
     1552        } 
     1553    } 
     1554    } 
     1555     
     1556    return $perl_exec; 
    15571557} 
    15581558 
     
    15631563    my $java = "java"; 
    15641564    if(defined $ENV{'GSDLHOME'}) { # should be, as this script would be launched from the cmd line  
    1565                                # after running setup.bat or from GLI which also runs setup.bat 
     1565    # after running setup.bat or from GLI which also runs setup.bat 
    15661566    my $java_bin = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'},"packages","jre","bin"); 
    15671567    if(-d $java_bin) { 
     
    15771577# returns the collection and colgroup parts 
    15781578sub get_collection_parts { 
    1579     # http://perldoc.perl.org/File/Basename.html 
    1580     # my($filename, $directories, $suffix) = fileparse($path); 
    1581     # "$directories contains everything up to and including the last directory separator in the $path  
    1582     # including the volume (if applicable). The remainder of the $path is the $filename." 
    1583     #my ($collection, $colgroup) = &File::Basename::fileparse($qualified_collection);    
    1584  
    1585     my $qualified_collection = shift(@_);  
    1586  
    1587     # Since activate.pl can be launched from the command-line, including by a user,  
    1588     # best not to assume colgroup uses URL-style slashes as would be the case with GLI 
    1589     # Also allow for the accidental inclusion of multiple slashes 
    1590     my ($colgroup, $collection) = split(/[\/\\]+/, $qualified_collection); #split('/', $qualified_collection); 
    1591      
    1592     if(!defined $collection) { 
    1593         $collection = $colgroup; 
    1594         $colgroup = ""; 
    1595     } 
    1596     return ($collection, $colgroup); 
     1579    # http://perldoc.perl.org/File/Basename.html 
     1580    # my($filename, $directories, $suffix) = fileparse($path); 
     1581    # "$directories contains everything up to and including the last directory separator in the $path  
     1582    # including the volume (if applicable). The remainder of the $path is the $filename." 
     1583    #my ($collection, $colgroup) = &File::Basename::fileparse($qualified_collection);    
     1584 
     1585    my $qualified_collection = shift(@_);  
     1586 
     1587    # Since activate.pl can be launched from the command-line, including by a user,  
     1588    # best not to assume colgroup uses URL-style slashes as would be the case with GLI 
     1589    # Also allow for the accidental inclusion of multiple slashes 
     1590    my ($colgroup, $collection) = split(/[\/\\]+/, $qualified_collection); #split('/', $qualified_collection); 
     1591     
     1592    if(!defined $collection) { 
     1593    $collection = $colgroup; 
     1594    $colgroup = ""; 
     1595    } 
     1596    return ($collection, $colgroup); 
    15971597} 
    15981598 
    15991599# work out the "collectdir/collection" location 
    16001600sub resolve_collection_dir { 
    1601     my ($collect_dir, $qualified_collection, $site) = @_; #, $gs_mode 
    1602      
    1603     if (defined $ENV{'GSDLCOLLECTDIR'}) { # a predefined collection dir exists 
    1604         return $ENV{'GSDLCOLLECTDIR'}; 
    1605     } 
    1606  
    1607     my ($colgroup, $collection) = &util::get_collection_parts($qualified_collection);    
    1608      
    1609     if (!defined $collect_dir || !$collect_dir) { # if undefined or empty string 
    1610         $collect_dir = &util::get_working_collect_dir($site); 
    1611     } 
    1612  
    1613     return &FileUtils::filenameConcatenate($collect_dir,$colgroup,$collection); 
     1601    my ($collect_dir, $qualified_collection, $site) = @_; #, $gs_mode 
     1602     
     1603    if (defined $ENV{'GSDLCOLLECTDIR'}) { # a predefined collection dir exists 
     1604    return $ENV{'GSDLCOLLECTDIR'}; 
     1605    } 
     1606 
     1607    my ($colgroup, $collection) = &util::get_collection_parts($qualified_collection);    
     1608     
     1609    if (!defined $collect_dir || !$collect_dir) { # if undefined or empty string 
     1610    $collect_dir = &util::get_working_collect_dir($site); 
     1611    } 
     1612 
     1613    return &FileUtils::filenameConcatenate($collect_dir,$colgroup,$collection); 
    16141614} 
    16151615 
     
    16731673    $path = &util::upgrade_if_dos_filename($path); # will only do something on windows 
    16741674    } 
    1675      
     1675     
    16761676    # now we know we're dealing with absolute paths and have to replace gs prefixes with placeholders 
    16771677    my @gs_paths = ($ENV{'GSDLCOLLECTDIR'}, $ENV{'GSDLCOLLECTHOME'}, $ENV{'SITEHOME'}, $ENV{'GREENSTONEHOME'}); # list in this order: from longest to shortest path 
     
    17261726        $path =~ s/^$re_path/$placeholder/; #case sensitive or not? 
    17271727        #$path =~ s/^[\\\/]//; # remove gs_path's trailing separator left behind at the start of the path 
    1728         # lowercase file extension, This is needed when shortfilenames are used, as case affects alphetical ordering, which affects diffcol      
    1729         $path =~ s/\.([A-Z]+)$/".".lc($1)/e; 
     1728        # lowercase file extension, This is needed when shortfilenames are used, as case affects alphetical ordering, which affects diffcol      
     1729        $path =~ s/\.([A-Z]+)$/".".lc($1)/e; 
    17301730        last; # done 
    17311731    } 
     
    17451745    # replace placeholders with gs prefixes 
    17461746    my @placeholders = ('@THISCOLLECTPATH@', '@COLLECTHOME@', '@SITEHOME@', '@GSDLHOME@'); # order of paths not crucial in this case,  
    1747                        # but listed here from longest to shortest once placeholders are have been resolved 
     1747    # but listed here from longest to shortest once placeholders are have been resolved 
    17481748 
    17491749    # can't use double-quotes around at-sign, else perl tries to evaluate it as referring to an array 
     
    17521752    # always replace placeholders with short file names of the absolute paths on windows? 
    17531753    %placeholder_to_gspath_map = ('@GSDLHOME@' => &util::downgrade_if_dos_filename($ENV{'GREENSTONEHOME'}), 
    1754                      '@COLLECTHOME@' => &util::downgrade_if_dos_filename($ENV{'GSDLCOLLECTHOME'}), 
    1755                      '@THISCOLLECTPATH@' => &util::downgrade_if_dos_filename($ENV{'GSDLCOLLECTDIR'}) 
    1756     ); 
     1754                      '@COLLECTHOME@' => &util::downgrade_if_dos_filename($ENV{'GSDLCOLLECTHOME'}), 
     1755                      '@THISCOLLECTPATH@' => &util::downgrade_if_dos_filename($ENV{'GSDLCOLLECTDIR'}) 
     1756        ); 
    17571757    $placeholder_to_gspath_map{'@SITEHOME@'} =  &util::downgrade_if_dos_filename($ENV{'SITEHOME'}) if defined $ENV{'SITEHOME'}; 
    17581758    } else { 
     
    17931793    my ($dir) = @_; 
    17941794    my ($pagenum) =($dir =~ m/^.*?[-\.]?(\d+)(\.(jpg|gif|png|txt))?$/i); 
    1795 #   my ($pagenum) =($dir =~ m/(\d+)(\.(jpg|gif|png))?$/i); # this works but is not as safe/strict about input filepatterns as the above 
     1795    #   my ($pagenum) =($dir =~ m/(\d+)(\.(jpg|gif|png))?$/i); # this works but is not as safe/strict about input filepatterns as the above 
    17961796 
    17971797    $pagenum = 1 unless defined $pagenum; 
     
    18211821    # We just test if a text file exists in the same dir that matches the name of the first image file 
    18221822    # if a matching txt file does not exist, don't output txtfile names into the item file 
    1823      
     1823     
    18241824    my ($tailname, $dirname, $suffix) = &File::Basename::fileparse($firstfile, "\\.[^\\.]+\$"); # relative filenames so no dirname 
    18251825    my $txtfilename = &FileUtils::filenameConcatenate($output_dir, $tailname . ".txt"); 
     
    18821882        } 
    18831883    } 
    1884      
     1884     
    18851885    # now set other the related env vars,  
    18861886    # IF we've found the gnome-lib dir installed in the ext folder   
     
    18891889        $ENV{'GEXTGNOME'} = $gnome_dir; 
    18901890        $ENV{'GEXTGNOME_INSTALLED'}=&FileUtils::filenameConcatenate($ENV{'GEXTGNOME'}, $ENV{'GSDLOS'}); 
    1891         
     1891         
    18921892        my $gnomelib_bin = &FileUtils::filenameConcatenate($ENV{'GEXTGNOME_INSTALLED'}, "bin"); 
    18931893        if(-d $gnomelib_bin) { # no bin subfolder in GS binary's cutdown gnome-lib-minimal folder 
     
    19121912    } 
    19131913 
    1914 #    print STDERR "@@@@@ GEXTGNOME: ".$ENV{'GEXTGNOME'}."\n\tINSTALL".$ENV{'GEXTGNOME_INSTALLED'}."\n"; 
    1915 #    print STDERR "\tPATH".$ENV{'PATH'}."\n"; 
    1916 #    print STDERR "\tLD_LIB_PATH".$ENV{'LD_LIBRARY_PATH'}."\n" if $ENV{'LD_LIBRARY_PATH}; 
    1917 #    print STDERR "\tDYLD_FALLBACK_LIB_PATH".$ENV{'DYLD_FALLBACK_LIBRARY_PATH'}."\n" if $ENV{'DYLD_FALLBACK_LIBRARY_PATH}; 
     1914    #    print STDERR "@@@@@ GEXTGNOME: ".$ENV{'GEXTGNOME'}."\n\tINSTALL".$ENV{'GEXTGNOME_INSTALLED'}."\n"; 
     1915    #    print STDERR "\tPATH".$ENV{'PATH'}."\n"; 
     1916    #    print STDERR "\tLD_LIB_PATH".$ENV{'LD_LIBRARY_PATH'}."\n" if $ENV{'LD_LIBRARY_PATH}; 
     1917    #    print STDERR "\tDYLD_FALLBACK_LIB_PATH".$ENV{'DYLD_FALLBACK_LIBRARY_PATH'}."\n" if $ENV{'DYLD_FALLBACK_LIBRARY_PATH}; 
    19181918 
    19191919    # if no GEXTGNOME, maybe users didn't need gnome-lib to run gnomelib/libiconv dependent binaries like hashfile, suffix, wget  
     
    19311931sub augmentINC 
    19321932{ 
    1933   my ($new_path) = @_; 
    1934   my $did_add_path = 0; 
    1935   # might need to be replaced with FileUtils::directoryExists() call eventually 
    1936   if (-d $new_path) 
    1937   { 
    1938     my $did_find_path = 0; 
    1939     foreach my $existing_path (@INC) 
     1933    my ($new_path) = @_; 
     1934    my $did_add_path = 0; 
     1935    # might need to be replaced with FileUtils::directoryExists() call eventually 
     1936    if (-d $new_path) 
    19401937    { 
    1941       if ($existing_path eq $new_path) 
    1942       { 
    1943         $did_find_path = 1; 
    1944         last; 
    1945       } 
    1946     } 
    1947     if (!$did_find_path) 
    1948     { 
    1949       unshift(@INC, $new_path); 
    1950       $did_add_path = 1; 
    1951     } 
    1952   } 
    1953   return $did_add_path; 
     1938    my $did_find_path = 0; 
     1939    foreach my $existing_path (@INC) 
     1940    { 
     1941        if ($existing_path eq $new_path) 
     1942        { 
     1943        $did_find_path = 1; 
     1944        last; 
     1945        } 
     1946    } 
     1947    if (!$did_find_path) 
     1948    { 
     1949        unshift(@INC, $new_path); 
     1950        $did_add_path = 1; 
     1951    } 
     1952    } 
     1953    return $did_add_path; 
    19541954} 
    19551955## augmentINC()