Changeset 27758


Ignore:
Timestamp:
07/05/13 14:53:19 (8 years ago)
Author:
ak19
Message:

Using FileUtils instead of deprecated util subroutines. Also a typo fix in FileUtils

Location:
main/trunk/greenstone2
Files:
3 edited

Legend:

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

    r25185 r27758  
    3636
    3737use util;
     38use FileUtils;
    3839use parse2;
    3940use printusage;
     
    5556    'type' => "string",
    5657    # parsearg left "" as default
    57     #'deft' => &util::filename_cat ($ENV{'GSDLHOME'}, "collect"),
     58    #'deft' => &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "collect"),
    5859    'deft' => "",
    5960    'reqd' => "no",
     
    105106    # the default/fallback for collect directory if none is provided
    106107    # (no -collectdir option given) is the standard Greenstone collect directory
    107     my $collectdir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect");
     108    my $collectdir = &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "collect");
    108109
    109110    my $hashParsingResult = {};
     
    162163    # first we do a quick check to see if the export coll function has been
    163164    # installed
    164     my $gssetupexe = &util::filename_cat ($ENV{'GSDLHOME'}, "bin", "windows", "gssetup.exe");
     165    my $gssetupexe = &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "bin", "windows", "gssetup.exe");
    165166    if (!-e $gssetupexe) {
    166167    &gsprintf($out, "{exportcol.fail} {exportcol.export_coll_not_installed}\n");
     
    171172    my @valid_coll_list = ();
    172173    foreach my $c (@coll_list) {
    173     my $colldir = &util::filename_cat ($collectdir, $c);
     174    my $colldir = &FileUtils::filenameConcatenate ($collectdir, $c);
    174175    if (! -d $colldir) {
    175176        &gsprintf($out, "{exportcol.coll_not_found}\n", $c, $colldir);
    176177        next;
    177178    }
    178     my $colindexdir = &util::filename_cat ($colldir, "index");
    179     my $coletcdir = &util::filename_cat ($colldir, "etc");
     179    my $colindexdir = &FileUtils::filenameConcatenate ($colldir, "index");
     180    my $coletcdir = &FileUtils::filenameConcatenate ($colldir, "etc");
    180181    if ((!-d $colindexdir) || (!-d $coletcdir)) {
    181182        &gsprintf($out, "{exportcol.coll_dirs_not_found}\n", $c);
     
    195196
    196197    # create exported directory
    197     my $topdir = &util::filename_cat ($ENV{'GSDLHOME'}, "tmp", $cddir);
    198     &util::mk_all_dir ($topdir);
     198    my $topdir = &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "tmp", $cddir);
     199    &FileUtils::makeAllDirectories ($topdir);
    199200    if (!-d $topdir) {
    200201    &gsprintf($out, "{exportcol.fail} {exportcol.couldnt_create_dir}\n", $topdir);
     
    212213    }
    213214    else {
    214     $gsdldir = &util::filename_cat ($topdir, "gsdl");
    215     &util::mk_all_dir ($gsdldir);
    216     }
    217    
    218     my $newcollectdir = &util::filename_cat ($gsdldir, "collect");
    219     &util::mk_all_dir ($newcollectdir);
    220     my $etcdir = &util::filename_cat ($gsdldir, "etc");
    221     &util::mk_all_dir ($etcdir);
     215    $gsdldir = &FileUtils::filenameConcatenate ($topdir, "gsdl");
     216    &FileUtils::makeAllDirectories ($gsdldir);
     217    }
     218   
     219    my $newcollectdir = &FileUtils::filenameConcatenate ($gsdldir, "collect");
     220    &FileUtils::makeAllDirectories ($newcollectdir);
     221    my $etcdir = &FileUtils::filenameConcatenate ($gsdldir, "etc");
     222    &FileUtils::makeAllDirectories ($etcdir);
    222223
    223224    #create the config files
    224225    if (!$noinstall) {
    225226    # create the install.cfg file
    226     my $installcfg = &util::filename_cat ($topdir, "install.cfg");
     227    my $installcfg = &FileUtils::filenameConcatenate ($topdir, "install.cfg");
    227228    if (!open (INSTALLCFG, ">$installcfg")) {
    228229        &gsprintf($out, "{exportcol.fail} {exportcol.couldnt_create_file}\n", $installcfg);
     
    238239   
    239240    # create the manifest.cfg file
    240     my $manifestcfg = &util::filename_cat ($topdir, "manifest.cfg");
     241    my $manifestcfg = &FileUtils::filenameConcatenate ($topdir, "manifest.cfg");
    241242    if (!open (MANIFESTCFG, ">$manifestcfg")) {
    242243        &gsprintf($out, "{exportcol.fail} {exportcol.couldnt_create_file}\n", $manifestcfg);
     
    260261
    261262    #create the autorun.inf file
    262     my $autoruninf = &util::filename_cat ($topdir, "Autorun.inf");
     263    my $autoruninf = &FileUtils::filenameConcatenate ($topdir, "Autorun.inf");
    263264    if (!open (AUTORUNINF, ">$autoruninf")) {
    264265    &gsprintf($out, "{exportcol.fail} {exportcol.couldnt_create_file}\n", $autoruninf);
     
    275276   
    276277    # copy the necessary stuff from GSDLHOME
    277     my $webdir = &util::filename_cat ($ENV{'GSDLHOME'}, "web");
    278     my $macrosdir = &util::filename_cat ($ENV{'GSDLHOME'}, "macros");
    279     my $mappingsdir = &util::filename_cat ($ENV{'GSDLHOME'}, "mappings");
    280     my $maincfg = &util::filename_cat ($ENV{'GSDLHOME'}, "etc", "main.cfg");
    281     my $serverexe = &util::filename_cat ($ENV{'GSDLHOME'}, "bin", "windows", "server.exe");
    282     my $setupexe = &util::filename_cat ($ENV{'GSDLHOME'}, "bin", "windows", "Setup.exe");
     278    my $webdir = &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "web");
     279    my $macrosdir = &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "macros");
     280    my $mappingsdir = &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "mappings");
     281    my $maincfg = &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "etc", "main.cfg");
     282    my $serverexe = &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "bin", "windows", "server.exe");
     283    my $setupexe = &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "bin", "windows", "Setup.exe");
    283284
    284285    if ((!-d $webdir) || (!-d $macrosdir) || (!-d $mappingsdir) || (!-e $maincfg) ||
     
    295296    }
    296297
    297     &util::cp_r_nosvn ($webdir, $gsdldir);
    298     &util::cp_r_nosvn ($macrosdir, $gsdldir);
    299     &util::cp_r_nosvn ($mappingsdir, $gsdldir);
    300     &util::cp ($maincfg, $etcdir);
    301     &util::cp ($serverexe, $gsdldir);
     298    &FileUtils::copyFilesRecursiveNoSVN ($webdir, $gsdldir);
     299    &FileUtils::copyFilesRecursiveNoSVN ($macrosdir, $gsdldir);
     300    &FileUtils::copyFilesRecursiveNoSVN ($mappingsdir, $gsdldir);
     301    &FileUtils::copyFiles ($maincfg, $etcdir);
     302    &FileUtils::copyFiles ($serverexe, $gsdldir);
    302303
    303304    if (!$noinstall) {
    304     &util::cp ($gssetupexe, $topdir);
    305     &util::cp ($setupexe, $topdir); # unused, since Setup.exe does not work on Win 7 64-bit
     305    &FileUtils::copyFiles ($gssetupexe, $topdir);
     306    &FileUtils::copyFiles ($setupexe, $topdir); # unused, since Setup.exe does not work on Win 7 64-bit
    306307    }   
    307308   
    308309    # now change the home.dm macro file to a simple version
    309     my $newmacrodir = &util::filename_cat ($gsdldir, "macros");
    310     my $exporthome = &util::filename_cat ($newmacrodir, "exported_home.dm");
    311     my $oldhome = &util::filename_cat ($newmacrodir, "home.dm");
     310    my $newmacrodir = &FileUtils::filenameConcatenate ($gsdldir, "macros");
     311    my $exporthome = &FileUtils::filenameConcatenate ($newmacrodir, "exported_home.dm");
     312    my $oldhome = &FileUtils::filenameConcatenate ($newmacrodir, "home.dm");
    312313    if (-e $exporthome) {
    313     &util::rm($oldhome);
    314     &util::mv($exporthome, $oldhome);
     314    &FileUtils::removeFiles($oldhome);
     315    &FileUtils::moveFiles($exporthome, $oldhome);
    315316    }
    316317
     
    318319    foreach my $c (@valid_coll_list) {
    319320    #old directories
    320     my $colldir = &util::filename_cat ($collectdir, $c);
    321     my $colindexdir = &util::filename_cat ($colldir, "index");
    322     my $coletcdir = &util::filename_cat ($colldir, "etc");
    323     my $colmacrosdir = &util::filename_cat ($colldir, "macros");
    324     my $colimagesdir = &util::filename_cat ($colldir, "images");
    325     my $colscriptdir = &util::filename_cat ($colldir, "script");
    326     my $coljavadir = &util::filename_cat ($colldir, "java");
    327     my $colstyledir = &util::filename_cat ($colldir, "style");
    328     my $colflashdir = &util::filename_cat ($colldir, "flash");
     321    my $colldir = &FileUtils::filenameConcatenate ($collectdir, $c);
     322    my $colindexdir = &FileUtils::filenameConcatenate ($colldir, "index");
     323    my $coletcdir = &FileUtils::filenameConcatenate ($colldir, "etc");
     324    my $colmacrosdir = &FileUtils::filenameConcatenate ($colldir, "macros");
     325    my $colimagesdir = &FileUtils::filenameConcatenate ($colldir, "images");
     326    my $colscriptdir = &FileUtils::filenameConcatenate ($colldir, "script");
     327    my $coljavadir = &FileUtils::filenameConcatenate ($colldir, "java");
     328    my $colstyledir = &FileUtils::filenameConcatenate ($colldir, "style");
     329    my $colflashdir = &FileUtils::filenameConcatenate ($colldir, "flash");
    329330
    330331    # new collection directory
     
    332333    my $new_c = $c;
    333334    $new_c =~ s/^.*[\/\\]//; # remove any folder info
    334     my $newcoldir = &util::filename_cat ($newcollectdir, $new_c);
    335 
    336     &util::mk_all_dir ($newcoldir);
    337     &util::cp_r_nosvn ($colindexdir, $newcoldir);
    338     &util::rename_ldb_or_bdb_file(&util::filename_cat ($newcoldir, "index", "text", $c));
    339     &util::cp_r_nosvn ($coletcdir, $newcoldir);
    340     &util::cp_r_nosvn ($colmacrosdir, $newcoldir) if (-e $colmacrosdir);
    341     &util::cp_r_nosvn ($colimagesdir, $newcoldir) if (-e $colimagesdir);
    342     &util::cp_r_nosvn ($colscriptdir, $newcoldir) if (-e $colscriptdir);
    343     &util::cp_r_nosvn ($coljavadir, $newcoldir) if (-e $coljavadir);
    344     &util::cp_r_nosvn ($colstyledir, $newcoldir) if (-e $colstyledir);
    345     &util::cp_r_nosvn ($colflashdir, $newcoldir) if (-e $colflashdir);
     335    my $newcoldir = &FileUtils::filenameConcatenate ($newcollectdir, $new_c);
     336
     337    &FileUtils::makeAllDirectories ($newcoldir);
     338    &FileUtils::copyFilesRecursiveNoSVN ($colindexdir, $newcoldir);
     339    &util::rename_ldb_or_bdb_file(&FileUtils::filenameConcatenate ($newcoldir, "index", "text", $c));
     340    &FileUtils::copyFilesRecursiveNoSVN ($coletcdir, $newcoldir);
     341    &FileUtils::copyFilesRecursiveNoSVN ($colmacrosdir, $newcoldir) if (-e $colmacrosdir);
     342    &FileUtils::copyFilesRecursiveNoSVN ($colimagesdir, $newcoldir) if (-e $colimagesdir);
     343    &FileUtils::copyFilesRecursiveNoSVN ($colscriptdir, $newcoldir) if (-e $colscriptdir);
     344    &FileUtils::copyFilesRecursiveNoSVN ($coljavadir, $newcoldir) if (-e $coljavadir);
     345    &FileUtils::copyFilesRecursiveNoSVN ($colstyledir, $newcoldir) if (-e $colstyledir);
     346    &FileUtils::copyFilesRecursiveNoSVN ($colflashdir, $newcoldir) if (-e $colflashdir);
    346347
    347348    # now we need to check the collect.cfg file to make sure it's public
    348     my $collectcfg = &util::filename_cat ($newcoldir, "etc", "collect.cfg");
     349    my $collectcfg = &FileUtils::filenameConcatenate ($newcoldir, "etc", "collect.cfg");
    349350    open INFILE, "<$collectcfg";
    350351    open OUTFILE, ">$collectcfg.tmp";
     
    364365    close INFILE;
    365366    close OUTFILE;
    366     &util::mv("$collectcfg.tmp", $collectcfg);
     367    &FileUtils::moveFiles("$collectcfg.tmp", $collectcfg);
    367368    }
    368369    &gsprintf($out, "{exportcol.success}");
  • main/trunk/greenstone2/bin/script/pdfpstoimg.pl

    r25994 r27758  
    3939use parsargv;
    4040use util;
     41use FileUtils;
    4142use Cwd;
    4243use File::Basename;
     
    7475    # test that the directories exist to create the output file, or
    7576    # we should exit immediately.
    76     &util::mk_dir($output_filestem) if (!-e $output_filestem);
     77    &FileUtils::makeDirectory($output_filestem) if (!-e $output_filestem);
    7778       
    7879    my @dir = split (/(\/|\\)/, $input_filename);
     
    9091    $cmd = "\"".&util::get_perl_exec()."\" -S gs-magick.pl convert";
    9192
    92     my $output_filename = &util::filename_cat($output_filestem, $input_basename);
     93    my $output_filename = &FileUtils::filenameConcatenate($output_filestem, $input_basename);
    9394    if ($convert_to eq "gif") {
    9495    $cmd .= " \"$input_filename\" \"$output_filename-%02d.$convert_to\"";
     
    104105    print STDERR "Convert error for $input_filename $!\n";
    105106    # leave these for gsConvert.pl...
    106     #&util::rm("$output_filestem.text") if (-e "$output_filestem.text");
    107     #&util::rm("$output_filestem.err") if (-e "$output_filestem.err");
     107    #&FileUtils::removeFiles("$output_filestem.text") if (-e "$output_filestem.text");
     108    #&FileUtils::removeFiles("$output_filestem.err") if (-e "$output_filestem.err");
    108109    return 1;
    109110    } else {
  • main/trunk/greenstone2/perllib/FileUtils.pm

    r27639 r27758  
    279279      # make the new directory
    280280      my ($filename) = $file =~ /([^\\\/]*)$/;
    281       $dest = &filenameConcatnate($dest, $filename);
     281      $dest = &filenameConcatenate($dest, $filename);
    282282      my $store_umask = umask(0002);
    283283      mkdir ($dest, 0777);
Note: See TracChangeset for help on using the changeset viewer.