Changeset 28563

Show
Ignore:
Timestamp:
31.10.2013 11:29:37 (6 years ago)
Author:
kjdon
Message:

changing some util:: methods to FileUtils:: methods

Location:
main/trunk/greenstone2/perllib/plugins
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/ArchivesInfPlugin.pm

    r27697 r28563  
    133133        print $outhandle "Removing $doc_dirname\n" if ($verbosity>2); 
    134134 
    135         &util::rm_r($doc_dirname); 
     135        &FileUtils::removeFilesRecursive($doc_dirname); 
    136136 
    137137 
  • main/trunk/greenstone2/perllib/plugins/CONTENTdmPlugin.pm

    r23352 r28563  
    263263    my ($page,$page_num,$tmp_dirname,$txt_file) = @_; 
    264264     
    265     my $txt_filename = &util::filename_cat($tmp_dirname,$txt_file); 
     265    my $txt_filename = &FileUtils::filenameConcatenate($tmp_dirname,$txt_file); 
    266266 
    267267    open(TOUT,">$txt_filename")  
     
    319319        } 
    320320        else { 
    321             $imgfile = &util::filename_cat("..","import",$imgfile); 
     321            $imgfile = &FileUtils::filenameConcatenate("..","import",$imgfile); 
    322322        } 
    323323         
     
    356356        } 
    357357        else { 
    358         $imgfile = &util::filename_cat("..","import",$imgfile); 
     358        $imgfile = &FileUtils::filenameConcatenate("..","import",$imgfile); 
    359359        } 
    360360 
     
    501501    # softlink to collection tmp dir 
    502502    my $tmp_dirname  
    503     = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "tmp"); 
    504     &util::mk_dir($tmp_dirname) if (!-e $tmp_dirname); 
     503    = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, "tmp"); 
     504    &FileUtils::makeDirectory($tmp_dirname) if (!-e $tmp_dirname); 
    505505 
    506506    # derive tmp filename from input filename 
     
    517517    $tailname = $self->SUPER::filepath_to_utf8($tailname) unless &unicode::check_is_utf8($tailname); 
    518518    $suffix = lc($suffix); 
    519     my $tmp_filename = &util::filename_cat($tmp_dirname, "$tailname$suffix"); 
    520  
    521     &util::soft_link($input_filename, $tmp_filename); 
     519    my $tmp_filename = &FileUtils::filenameConcatenate($tmp_dirname, "$tailname$suffix"); 
     520 
     521    &FileUtils::softLink($input_filename, $tmp_filename); 
    522522    my $verbosity = $self->{'verbosity'}; 
    523523    if ($verbosity > 0) { 
     
    525525    } 
    526526 
    527     my $errlog = &util::filename_cat($tmp_dirname, "err.log"); 
     527    my $errlog = &FileUtils::filenameConcatenate($tmp_dirname, "err.log"); 
    528528     
    529529    # call xml_area_convert_file rather than gsConvert.pl 
    530530 
    531     my $output_root = &util::filename_cat($tmp_dirname, "$tailname"); 
     531    my $output_root = &FileUtils::filenameConcatenate($tmp_dirname, "$tailname"); 
    532532 
    533533    my ($output_type,$item_files)  
     
    535535 
    536536 
    537     my $fakeimg_filename = &util::filename_cat($dirname, "empty.jpg"); 
    538     my $fakeimg_tmp_filename = &util::filename_cat($tmp_dirname, "empty.jpg"); 
     537    my $fakeimg_filename = &FileUtils::filenameConcatenate($dirname, "empty.jpg"); 
     538    my $fakeimg_tmp_filename = &FileUtils::filenameConcatenate($tmp_dirname, "empty.jpg"); 
    539539 
    540540    print STDERR "***** No source image identified with item\n"; 
     
    542542    print STDERR "***** Using default \"no image available\" $fakeimg_filename -> $fakeimg_tmp_filename\n"; 
    543543 
    544     &util::soft_link($fakeimg_filename, $fakeimg_tmp_filename); 
     544    &FileUtils::softLink($fakeimg_filename, $fakeimg_tmp_filename); 
    545545    
    546546    # continue as before ... 
    547547 
    548548    # remove symbolic link to original file 
    549     &util::rm($tmp_filename); 
     549    &FileUtils::removeFiles($tmp_filename); 
    550550 
    551551    # Check STDERR here 
     
    563563        close ERRLOG; 
    564564    } 
    565     &util::rm("$errlog") if (-e "$errlog"); 
     565    &FileUtils::removeFiles("$errlog") if (-e "$errlog"); 
    566566    return []; 
    567567    } 
  • main/trunk/greenstone2/perllib/plugins/ConvertToRogPlugin.pm

    r24362 r28563  
    3232no strict 'refs'; # allow filehandles to be variables and viceversa 
    3333use util; 
     34use FileUtils; 
    3435 
    3536sub BEGIN { 
     
    9697    # softlink to collection tmp dir 
    9798    my $tmp_dirname  
    98     = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "tmp"); 
    99     &util::mk_dir($tmp_dirname) if (!-e $tmp_dirname); 
     99    = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, "tmp"); 
     100    &FileUtils::makeDirectory($tmp_dirname) if (!-e $tmp_dirname); 
    100101 
    101102    # derive tmp filename from input filename 
     
    108109    $tailname = $self->SUPER::filepath_to_utf8($tailname) unless &unicode::check_is_utf8($tailname); 
    109110 
    110     my $tmp_filename = &util::filename_cat($tmp_dirname, "$tailname$suffix"); 
    111  
    112     &util::soft_link($input_filename, $tmp_filename); 
     111    my $tmp_filename = &FileUtils::filenameConcatenate($tmp_dirname, "$tailname$suffix"); 
     112 
     113    &FileUtils::softLink($input_filename, $tmp_filename); 
    113114 
    114115    my $verbosity = $self->{'verbosity'}; 
     
    117118    } 
    118119 
    119     my $errlog = &util::filename_cat($tmp_dirname, "err.log"); 
     120    my $errlog = &FileUtils::filenameConcatenate($tmp_dirname, "err.log"); 
    120121     
    121122    # Execute the conversion command and get the type of the result, 
     
    126127 
    127128    # remove symbolic link to original file 
    128     &util::rm($tmp_filename); 
     129    &FileUtils::removeFiles($tmp_filename); 
    129130 
    130131    # Check STDERR here 
     
    142143        close ERRLOG; 
    143144    } 
    144     &util::rm("$errlog") if (-e "$errlog"); 
     145    &FileUtils::removeFiles("$errlog") if (-e "$errlog"); 
    145146    return ""; 
    146147    } 
     
    166167 
    167168    my $tmp_dirname  
    168     = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "tmp"); 
    169     &util::rm_r($tmp_dirname); 
    170     &util::mk_dir($tmp_dirname); 
     169    = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, "tmp"); 
     170    &FileUtils::removeFilesRecursive($tmp_dirname); 
     171    &FileUtils::makeDirectory($tmp_dirname); 
    171172} 
    172173 
     
    444445    # associate original file with doc object 
    445446    my $cursection = $doc_obj->get_top_section(); 
    446     my $filename = &util::filename_cat($base_dir, $file); 
     447    my $filename = &FileUtils::filenameConcatenate($base_dir, $file); 
    447448    $doc_obj->associate_file($filename, "doc.$doc_ext", undef, $cursection); 
    448449 
  • main/trunk/greenstone2/perllib/plugins/DSpacePlugin.pm

    r24971 r28563  
    5151use plugin; 
    5252use util; 
     53use FileUtils; 
    5354use XMLParser; 
    5455use strict; 
     
    148149 
    149150    my ($tailname, $contents_basedir, $suffix) = &File::Basename::fileparse($filename_full_path, "\\.[^\\.]+\$"); 
    150     my $handle_filename = &util::filename_cat($contents_basedir,"handle"); 
    151  
    152     if (&util::fd_exists($handle_filename)) { 
     151    my $handle_filename = &FileUtils::filenameConcatenate($contents_basedir,"handle"); 
     152 
     153    if (&FileUtils::fileTest($handle_filename)) { 
    153154    &util::block_filename($block_hash,$handle_filename); 
    154155    } 
     
    164165    my @assocmime_list = (); 
    165166 
    166     my $content_fname = &util::filename_cat($dir,"contents"); 
     167    my $content_fname = &FileUtils::filenameConcatenate($dir,"contents"); 
    167168 
    168169    open(CIN,"<$content_fname")  
     
    274275    my $outhandle = $self->{'outhandle'}; 
    275276     
    276     my $filename = &util::filename_cat($base_dir, $file); 
     277    my $filename = &FileUtils::filenameConcatenate($base_dir, $file); 
    277278    # return 0 if $self->{'block_exp'} ne "" && $filename =~ /$self->{'block_exp'}/; 
    278279     
     
    302303    if ($only_first_doc || $first_inorder_ext || $first_inorder_mime) {  
    303304    foreach my $afm ( @$assoc_file_mimes ) { 
    304         my $full_af = &util::filename_cat($dir,$afm->{'file'}); 
     305        my $full_af = &FileUtils::filenameConcatenate($dir,$afm->{'file'}); 
    305306        $self->{'extra_blocks'}->{$full_af} = 1; 
    306307    } 
     
    334335 
    335336    my @gsdlassocfile_tobe  
    336         = map { &util::filename_cat($dir,$_->{'file'}) .":".$_->{'mimetype'}.":" } @$assoc_file_mimes if @$assoc_file_mimes; 
     337        = map { &FileUtils::filenameConcatenate($dir,$_->{'file'}) .":".$_->{'mimetype'}.":" } @$assoc_file_mimes if @$assoc_file_mimes; 
    337338    $self->{'saved_metadata'}->{'gsdlassocfile_tobe'} = \@gsdlassocfile_tobe; 
    338339 
     
    355356     
    356357    # Block all files except contents 
    357     my $filename = &util::filename_cat($base_dir, $file); 
     358    my $filename = &FileUtils::filenameConcatenate($base_dir, $file); 
    358359    return 0 if $self->{'block_exp'} ne "" && $filename =~ /$self->{'block_exp'}/; 
    359360 
  • main/trunk/greenstone2/perllib/plugins/EmailPlugin.pm

    r25741 r28563  
    7474 
    7575use sorttools; 
    76 use util; 
     76use FileUtils; 
    7777 
    7878sub BEGIN { 
     
    458458    foreach my $tmp_file_path (@{$self->{'tmp_file_paths'}}) { 
    459459        if (-e $tmp_file_path) { 
    460             &util::rm($tmp_file_path); 
     460            &FileUtils::removeFiles($tmp_file_path); 
    461461        } 
    462462    } 
     
    806806        $encoding=$1; $encoding =~ tr/A-Z/a-z/; 
    807807        } 
    808         my $tmpdir=&util::filename_cat($ENV{'GSDLHOME'}, "tmp"); 
     808        my $tmpdir=&FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "tmp"); 
    809809        my $save_filename=$filename; 
    810810         
     
    821821        $assoc_files->{$filename}=1; 
    822822        } 
    823         my $tmp_filename = &util::filename_cat($tmpdir, $save_filename); 
     823        my $tmp_filename = &FileUtils::filenameConcatenate($tmpdir, $save_filename); 
    824824        open (SAVE, ">$tmp_filename") || 
    825825        warn "EMAILPlug: Can't save attachment as $tmp_filename: $!"; 
  • main/trunk/greenstone2/perllib/plugins/HTMLImagePlugin.pm

    r24600 r28563  
    365365    if ( $self->{'aggressiveness'} >=5 && $self->{'aggressiveness'} != 9 ) { 
    366366    $self->{'stopwords'} = (); 
    367     $filepath = &util::filename_cat($ENV{'GSDLHOME'}, "etc", "packages", "phind", "stopword", "en", "brown.sw"); 
     367    $filepath = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "etc", "packages", "phind", "stopword", "en", "brown.sw"); 
    368368    if ( open STOPWORDS, "<$filepath" ) { 
    369369        while ( <STOPWORDS> ) { 
     
    407407    $base_dir =~ /(.*)\/.*/; 
    408408    $tndir = "$1/archives/thumbnails"; # TODO: this path shouldn't be hardcoded? 
    409     &util::mk_all_dir($tndir) unless -e "$tndir";  
     409    &FileUtils::makeAllDirectories($tndir) unless -e "$tndir";  
    410410 
    411411    $imgs = \%{$self->{'imglist'}}; 
  • main/trunk/greenstone2/perllib/plugins/ISISPlugin.pm

    r27502 r28563  
    3232use SplitTextFile; 
    3333use MetadataRead; 
     34use FileUtils; 
    3435 
    3536use strict; 
     
    448449 
    449450    # Delete the FDT and XRF files too 
    450     &util::rm($self->{'fdt_file_path'}); 
    451     &util::rm($self->{'xrf_file_path'}); 
     451    &FileUtils::removeFiles($self->{'fdt_file_path'}); 
     452    &FileUtils::removeFiles($self->{'xrf_file_path'}); 
    452453} 
    453454 
  • main/trunk/greenstone2/perllib/plugins/TextPlugin.pm

    r17739 r28563  
    163163    $tmp_dirname = $ENV{'GSDLHOME'}; 
    164164    } 
    165     $tmp_dirname = &util::filename_cat($tmp_dirname, "tmp"); 
    166     &util::mk_dir($tmp_dirname) if (!-e $tmp_dirname); 
     165    $tmp_dirname = &FileUtils::filenameConcatenate($tmp_dirname, "tmp"); 
     166    &FileUtils::makeDirectory($tmp_dirname) if (!-e $tmp_dirname); 
    167167 
    168168    # convert to utf-8 otherwise we have problems with the doc.xml file 
     
    171171 
    172172    $suffix = lc($suffix); 
    173     my $tmp_filename = &util::filename_cat($tmp_dirname, "$tailname$suffix");  
     173    my $tmp_filename = &FileUtils::filenameConcatenate($tmp_dirname, "$tailname$suffix");  
    174174     
    175175    # Make sure we have the absolute path to the input file 
     
    181181    # Now make the softlink,  so we don't accidentally damage the input file 
    182182    # softlinking creates a symbolic link to (or, if that's not possible, it makes a copy of) the original 
    183     &util::soft_link($input_filename, $tmp_filename, $ensure_path_absolute); 
     183    &FileUtils::softLink($input_filename, $tmp_filename, $ensure_path_absolute); 
    184184      
    185185    my $verbosity = $self->{'verbosity'}; 
     
    191191 
    192192    #my $output_filename = $tailname$output_ext; #output_ext has to be html! 
    193     my $output_filename = &util::filename_cat($tmp_dirname, $tailname.".html"); 
     193    my $output_filename = &FileUtils::filenameConcatenate($tmp_dirname, $tailname.".html"); 
    194194     
    195195    # Read contents of text file line by line into an array 
     
    227227 
    228228    # remove the copy of the original file/remove the symbolic link to original file 
    229     &util::rm($tmp_filename); 
     229    &FileUtils::removeFiles($tmp_filename); 
    230230 
    231231    return $output_filename; # return the output file path 
  • main/trunk/greenstone2/perllib/plugins/WordPlugin.pm

    r24176 r28563  
    310310        my @wmz_files = grep( /\.wmz$/, readdir(DIN)); 
    311311        foreach my $f (@wmz_files) { 
    312         my $full_f = &util::filename_cat($html_files_dir,$f); 
    313         &util::rm($full_f); 
     312        my $full_f = &FileUtils::filenameConcatenate($html_files_dir,$f); 
     313        &FileUtils::removeFiles($full_f); 
    314314        } 
    315315        closedir(DIN);