Changeset 27519

Show
Ignore:
Timestamp:
30.05.2013 15:20:33 (6 years ago)
Author:
ak19
Message:

Using the recommended FileUtils?.pm equivalents for util.pm subroutines.

Location:
main/trunk/greenstone2
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/bin/script/wvware.pl

    r24829 r27519  
    4040use strict; 
    4141use util; 
     42use FileUtil; 
    4243 
    4344# Are we running on WinNT or Win2000 (or later)? 
     
    8081    # my $extdesc = "the GNOME support library extension"; 
    8182 
    82     my $extdir = &util::filename_cat($ENV{'GSDLHOME'},"ext"); 
    83     my $gnome_dir = &util::filename_cat($extdir, "gnome-lib-minimal"); 
     83    my $extdir = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'},"ext"); 
     84    my $gnome_dir = &FileUtils::filenameConcatenate($extdir, "gnome-lib-minimal"); 
    8485    if(-d $gnome_dir) { 
    8586        $ENV{'GEXTGNOME'} = $gnome_dir; 
    8687    } else { 
    87         $gnome_dir = &util::filename_cat($extdir, "gnome-lib"); 
     88        $gnome_dir = &FileUtils::filenameConcatenate($extdir, "gnome-lib"); 
    8889        if(-d $gnome_dir) { 
    8990        $ENV{'GEXTGNOME'} = $gnome_dir; 
     
    9798 
    9899    if (defined $ENV{'GEXTGNOME'}) { 
    99         $ENV{'GEXTGNOME_INSTALLED'}=&util::filename_cat($ENV{'GEXTGNOME'}, $ENV{'GSDLOS'}); 
     100        $ENV{'GEXTGNOME_INSTALLED'}=&FileUtils::filenameConcatenate($ENV{'GEXTGNOME'}, $ENV{'GSDLOS'}); 
    100101         
    101         &util::envvar_prepend("PATH", &util::filename_cat($ENV{'GEXTGNOME_INSTALLED'}, "bin")); 
     102        &util::envvar_prepend("PATH", &FileUtils::filenameConcatenate($ENV{'GEXTGNOME_INSTALLED'}, "bin")); 
    102103         
    103104        # util's prepend will create LD/DYLD_LIB_PATH if it doesn't exist yet 
    104         my $gextlib = &util::filename_cat($ENV{'GEXTGNOME_INSTALLED'}, "lib"); 
     105        my $gextlib = &FileUtils::filenameConcatenate($ENV{'GEXTGNOME_INSTALLED'}, "lib"); 
    105106        if($ENV{'GSDLOS'} eq "linux") { 
    106107        &util::envvar_prepend("LD_LIBRARY_PATH", $gextlib); 
     
    122123    # RUN WVWARE 
    123124 
    124     my $wvWare = &util::filename_cat($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "wvWare"); 
    125  
    126     my $wvware_folder = &util::filename_cat($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "wv"); 
     125    my $wvWare = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "wvWare"); 
     126 
     127    my $wvware_folder = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "wv"); 
    127128    if ( -d $wvware_folder && $ENV{'GSDLOS'} eq "linux" ) { 
    128     &util::envvar_prepend("PATH", &util::filename_cat($wvware_folder, "bin")); 
    129  
    130     my $wvwarelib = &util::filename_cat($wvware_folder, "lib"); 
     129    &util::envvar_prepend("PATH", &FileUtils::filenameConcatenate($wvware_folder, "bin")); 
     130 
     131    my $wvwarelib = &FileUtils::filenameConcatenate($wvware_folder, "lib"); 
    131132    if($ENV{'GSDLOS'} eq "linux") { 
    132133        &util::envvar_prepend("LD_LIBRARY_PATH", $wvwarelib); 
     
    134135       # &util::envvar_prepend("DYLD_LIBRARY_PATH", $wvwarelib); 
    135136    #} 
    136         $wvWare = &util::filename_cat($wvware_folder, "bin", "wvWare"); 
     137        $wvWare = &FileUtils::filenameConcatenate($wvware_folder, "bin", "wvWare"); 
    137138    } 
    138139 
     
    142143    $wvWare = "wvWare" if ($ENV{'GSDLOS'} =~ m/^windows$/i); 
    143144 
    144     my $wv_conf = &util::filename_cat($ENV{'GSDLHOME'}, "etc",  
     145    my $wv_conf = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "etc",  
    145146                      "packages", "wv", "wvHtml.xml"); 
    146147     
     
    185186    # would generate ($windows_scripting) when it converts from word to html. 
    186187    # That is, foldername=docname_files 
    187     my $assoc_dir = &util::filename_cat($toppath, $docname."_files"); 
     188    my $assoc_dir = &FileUtils::filenameConcatenate($toppath, $docname."_files"); 
    188189    #print "assoc_dir: ".$assoc_dir."\n";  # same as "$output_filestem._files" 
    189190     
     
    191192    # if it exists already, just delete and recreate 
    192193    if(-e $assoc_dir) {  
    193     &util::rm_r($assoc_dir); 
     194    &FileUtils::removeFilesRecursive($assoc_dir); 
    194195    }   
    195     &util::mk_dir($assoc_dir); 
     196    &FileUtils::makeDirectory($assoc_dir); 
    196197 
    197198    # the images are all going to be called image0, image1,..., imageN 
    198     my $img_basenames = &util::filename_cat($assoc_dir, $docname); 
     199    my $img_basenames = &FileUtils::filenameConcatenate($assoc_dir, $docname); 
    199200     
    200201    #print STDERR "****toppath: $toppath\n****docname: $docname\n; 
     
    254255    close(TMP); 
    255256    if ($line && $line =~ m/DOCTYPE HTML/) { 
    256         &util::rm("$output_filestem.err") if -e "$output_filestem.err";     
     257        &FileUtils::removeFiles("$output_filestem.err") if -e "$output_filestem.err";     
    257258 
    258259        # Inserted this code to remove the images directory if it was still empty after  
    259260        # the html was generated (in case there were no images in the word document) 
    260         if (&util::is_dir_empty($assoc_dir)) { 
     261        if (&FileUtils::isDirectoryEmpty($assoc_dir)) { 
    261262        #print STDERR "***gsConvert.pl: Image dir $assoc_dir is empty, removing***\n"; 
    262         &util::rm_r($assoc_dir); 
     263        &FileUtils::removeFilesRecursive($assoc_dir); 
    263264        } else { # there was an image folder (it was generated) 
    264265        # Therefore, the html file generated contains absolute links to the images 
     
    271272     
    272273    # If here, an error of some sort occurred 
    273     &util::rm("$output_filestem.html") if -e "$output_filestem.html"; 
     274    &FileUtils::removeFiles("$output_filestem.html") if -e "$output_filestem.html"; 
    274275    if (-e "$output_filestem.err") { 
    275276    if ($faillogfile ne "" && defined(open(FAILLOG,">>$faillogfile"))) { 
     
    279280        close ERRLOG; 
    280281    } 
    281     &util::rm("$output_filestem.err"); 
     282    &FileUtils::removeFiles("$output_filestem.err"); 
    282283    } 
    283284     
     
    362363    # delete the original file and recreate it 
    363364    my $copy_of_filename = $html_file; 
    364     &util::rm($copy_of_filename); # deleted the file 
     365    &FileUtils::removeFiles($copy_of_filename); # deleted the file 
    365366 
    366367    # Recreate the original file for writing the updated contents 
  • main/trunk/greenstone2/perllib/plugins/ImageConverter.pm

    r27354 r27519  
    3333 
    3434use util; 
     35use FileUtils; 
    3536use gsprintf 'gsprintf'; 
    3637 
     
    232233    # check the size of the image against minimum size if specified 
    233234    my $minimumsize = $self->{'minimumsize'}; 
    234     if (defined $minimumsize && (-s $filename_full_path < $minimumsize)) { 
     235    if (defined $minimumsize && (&FileUtils::fileSize($filename_full_path) < $minimumsize)) { 
    235236        print $outhandle "ImageConverter: \"$filename_full_path\" too small, skipping\n" 
    236237        if ($verbosity > 1); 
     
    319320    #overwrite the ones added in BasePlugin 
    320321    $doc_obj->set_metadata_element ($section, "FileFormat", $type); 
    321     my $sys_file_size = -s $filename_full_path; 
     322    my $sys_file_size = &FileUtils::fileSize($filename_full_path); 
    322323    $doc_obj->set_metadata_element ($section, "FileSize",   $sys_file_size); #$image_size); 
    323324