Ignore:
Timestamp:
2013-05-06T15:29:38+12:00 (11 years ago)
Author:
jmt12
Message:

Moving the critical file-related functions (copy, rm, etc) out of util.pm into their own proper class FileUtils. Use of the old functions in util.pm will prompt deprecated warning messages. There may be further functions that could be moved across in the future, but these are the critical ones when considering supporting other filesystems (HTTP, HDFS, WebDav, etc). Updated some key files to use the new functions so now deprecated messages thrown when importing/building demo collection 'out of the box'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugouts/BasePlugout.pm

    r27071 r27306  
    3636use printusage;
    3737use parse2;
    38 
     38use util;
     39use FileUtils;
    3940
    4041# suppress the annoying "subroutine redefined" warning that various
     
    509510        my $output_dir = $self->get_output_dir();
    510511        &util::mk_all_dir ($output_dir) unless -e $output_dir;
    511         my $doc_file = &util::filename_cat ($output_dir, $doc_dir, "doc.xml");
    512         my $short_doc_file = &util::filename_cat ($doc_dir, "doc.xml");
     512        my $doc_file = &FileUtils::filenameConcatenate($output_dir, $doc_dir, "doc.xml");
     513        my $short_doc_file = &FileUtils::filenameConcatenate($doc_dir, "doc.xml");
    513514       
    514515        if ($gs_count>0)
     
    590591
    591592    if (!defined $self->{'group'} || !$self->{'group'}){
    592     &util::mk_all_dir (&util::filename_cat ($working_dir, $doc_dir));
     593    &FileUtils::makeAllDirectories(&FileUtils::filenameConcatenate($working_dir, $doc_dir));
    593594    }
    594595
     
    619620       }
    620621   } while ($doc_dir_rest ne "" &&
    621         ((-d &util::filename_cat ($working_dir, "$doc_dir.dir")) ||
     622        ((-d &FileUtils::filenameConcatenate($working_dir, "$doc_dir.dir")) ||
    622623         ($working_info->size() >= 1024 && $doc_dir_num < 2)));
    623624   my $i = 1;
    624625   my $doc_dir_base = $doc_dir;
    625    while (-d &util::filename_cat ($working_dir, "$doc_dir.dir")) {
     626   while (-d &FileUtils::filenameConcatenate($working_dir, "$doc_dir.dir")) {
    626627       $doc_dir = "$doc_dir_base-$i";
    627628       $i++;
     
    642643    &util::mk_all_dir ($output_dir) unless -e $output_dir;
    643644     
    644     my $working_dir = &util::filename_cat($output_dir, $doc_dir);
     645    my $working_dir = &FileUtils::filenameConcatenate($output_dir, $doc_dir);
    645646    &util::mk_all_dir ($working_dir) unless -e $working_dir;
    646647
     
    662663     
    663664    if ($source_filename !~ /^$dirsep_regexp/) {
    664         $source_filename = &util::filename_cat($collect_dir, $source_filename);
     665        $source_filename = &FileUtils::filenameConcatenate($collect_dir, $source_filename);
    665666    }
    666667    }
     
    686687    if (-e $real_filename) {
    687688
    688         $filename = &util::filename_cat($working_dir, $afile);
    689 
    690         &util::hard_link ($real_filename, $filename, $self->{'verbosity'});
    691        
     689        $filename = &FileUtils::filenameConcatenate($working_dir, $afile);
     690
     691            &FileUtils::hardLink($real_filename, $filename, $self->{'verbosity'});
     692
    692693        $doc_obj->add_utf8_metadata ($doc_obj->get_top_section(),
    693694                     "gsdlassocfile",
     
    815816    }
    816817
    817     my $rss_filename = &util::filename_cat($output_dir,"rss-items.rdf");
     818    my $rss_filename = &FileUtils::filenameConcatenate($output_dir,"rss-items.rdf");
    818819    if (open(RSSOUT,">>$rss_filename")) {
    819820        print RSSOUT "<item>\n";
     
    875876    return unless defined $xslt_file and $xslt_file ne "" and -e $xslt_file;
    876877   
    877     my $java_class_path =  &util::filename_cat ($ENV{'GSDLHOME'},"bin","java","ApplyXSLT.jar");
     878    my $java_class_path =  &FileUtils::filenameConcatenate($ENV{'GSDLHOME'},"bin","java","ApplyXSLT.jar");
    878879
    879880    my $mapping_file_path = "";
    880881
    881882    if ($ENV{'GSDLOS'} eq "windows"){
    882     $java_class_path .=";".&util::filename_cat ($ENV{'GSDLHOME'},"bin","java","xalan.jar");
     883    $java_class_path .=";".&FileUtils::filenameConcatenate($ENV{'GSDLHOME'},"bin","java","xalan.jar");
    883884    # this file:/// bit didn't work for me on windows XP
    884885    #$xslt_file = "\"file:///".$xslt_file."\"";
     
    886887    }
    887888    else{
    888     $java_class_path .=":".&util::filename_cat ($ENV{'GSDLHOME'},"bin","java","xalan.jar");
     889    $java_class_path .=":".&FileUtils::filenameConcatenate($ENV{'GSDLHOME'},"bin","java","xalan.jar");
    889890    }
    890891
Note: See TracChangeset for help on using the changeset viewer.