Index: /main/trunk/greenstone2/bin/script/build
===================================================================
--- /main/trunk/greenstone2/bin/script/build	(revision 29370)
+++ /main/trunk/greenstone2/bin/script/build	(revision 29371)
@@ -60,4 +60,5 @@
 use parsargv;
 use util;
+use FileUtils;
 use cfgread;
 use colcfg;
@@ -72,6 +73,6 @@
 my $path_separator = ":";
 $path_separator = ";" if $ENV{'GSDLOS'} =~ /^windows$/;
-$ENV{'PATH'} = &util::filename_cat($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}) .
-    $path_separator . &util::filename_cat($ENV{'GSDLHOME'}, "bin", "script") .
+$ENV{'PATH'} = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}) .
+    $path_separator . &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "bin", "script") .
     $path_separator . $ENV{'PATH'};
 
@@ -111,19 +112,19 @@
 {
     die "GSDL3HOME not set." unless $ENV{'GSDL3HOME'};
-    $cdir = &util::filename_cat ($ENV{'GSDL3HOME'}, "sites", $site, "collect") unless $collectdir =~ /\w/;
+    $cdir = &FileUtils::filenameConcatenate ($ENV{'GSDL3HOME'}, "sites", $site, "collect") unless $collectdir =~ /\w/;
     $gs_mode = "gs3";
 }
 else
 {
-    $cdir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect") unless $collectdir =~ /\w/;
+    $cdir = &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "collect") unless $collectdir =~ /\w/;
     $gs_mode = "gs2";
 }
 
-my $importdir = &util::filename_cat ($cdir, $collection, "import");
-my $archivedir = &util::filename_cat ($cdir, $collection, "archives");
-my $buildingdir = &util::filename_cat ($cdir, $collection, "building");
-my $indexdir = &util::filename_cat ($cdir, $collection, "index");
-my $etcdir = &util::filename_cat ($cdir, $collection, "etc");
-my $bindir = &util::filename_cat ($ENV{'GSDLHOME'}, "bin");
+my $importdir = &FileUtils::filenameConcatenate ($cdir, $collection, "import");
+my $archivedir = &FileUtils::filenameConcatenate ($cdir, $collection, "archives");
+my $buildingdir = &FileUtils::filenameConcatenate ($cdir, $collection, "building");
+my $indexdir = &FileUtils::filenameConcatenate ($cdir, $collection, "index");
+my $etcdir = &FileUtils::filenameConcatenate ($cdir, $collection, "etc");
+my $bindir = &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "bin");
 
 my $use_out = 0;
@@ -134,5 +135,5 @@
     
     # delete any existing .final file
-    &util::rm ("$outfile.final") if -e "$outfile.final";
+    &FileUtils::removeFiles ("$outfile.final") if -e "$outfile.final";
 
     $use_out = 1;
@@ -141,11 +142,11 @@
 
 # delete any .kill file left laying around from a previously aborted build
-if (-e &util::filename_cat ($cdir, $collection, ".kill")) {
-    &util::rm (&util::filename_cat ($cdir, $collection, ".kill"));
+if (-e &FileUtils::filenameConcatenate ($cdir, $collection, ".kill")) {
+    &FileUtils::removeFiles (&FileUtils::filenameConcatenate ($cdir, $collection, ".kill"));
 }
 
 # get maintainer email address from main.cfg
 my $maintainer = "NULL";
-my $main_cfg = &util::filename_cat ($ENV{'GSDLHOME'}, "etc", "main.cfg");
+my $main_cfg = &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "etc", "main.cfg");
 my $cfgdata = &cfgread::read_cfg_file ($main_cfg, "maintainer");
 if (defined $cfgdata->{'maintainer'} && $cfgdata->{'maintainer'} =~ /\w/) {
@@ -166,10 +167,10 @@
     my ($final_etcdir);
     if ($dontinstall) {
-	$final_etcdir = &util::filename_cat($collectdir, "etc", "build.log");
+	$final_etcdir = &FileUtils::filenameConcatenate($collectdir, "etc", "build.log");
     } else {
-	$final_etcdir = &util::filename_cat($ENV{'GSDLHOME'}, "collect", $collection, "etc", "build.log");
+	$final_etcdir = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "collect", $collection, "etc", "build.log");
     }
     
-    &util::cp($outfile, $final_etcdir);
+    &FileUtils::copyFiles($outfile, $final_etcdir);
 }
 
@@ -204,5 +205,5 @@
     print STDOUT "                           a -download option is supplied\n";
     print STDOUT "   -collectdir directory   Collection directory (defaults to " .
-	&util::filename_cat($ENV{'GSDLHOME'}). "collect for Greenstone2;\n";
+	&FileUtils::filenameConcatenate($ENV{'GSDLHOME'}). "collect for Greenstone2;\n";
     print STDOUT"                            for Greenstone3 use -site option and then collectdir default will be\n";
     print STDOUT "                            set to the collect folder within that site.)\n";
@@ -225,5 +226,5 @@
     print STDOUT "                           etc.) to event_log_file\n";
     print STDOUT "   -event_log_file file    File to append important events to (defaults to\n";
-    print STDOUT "                           " . &util::filename_cat ($ENV{'GSDLHOME'}, "etc", "events.txt") . "\n";
+    print STDOUT "                           " . &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "etc", "events.txt") . "\n";
     print STDOUT "   -email_events addr      Comma separated list of email addresses to mail\n";
     print STDOUT "                           details of important collection building events\n";
@@ -242,5 +243,5 @@
     if ($save_archives && -d $archivedir) {
 	print $out "caching original archives to ${archivedir}.org\n";
-	&util::cp_r ($archivedir, "${archivedir}.org");
+	&FileUtils::copyFilesRecursive ($archivedir, "${archivedir}.org");
     }
 
@@ -250,5 +251,5 @@
 	if (&has_content ($importdir)) {
 	    #print $out "build: WARNING: removing contents of $importdir\n";
-	    #&util::rm_r ($importdir);
+	    #&FileUtils::removeFilesRecursive ($importdir);
 	}
 	
@@ -294,8 +295,8 @@
 			next if $file =~ /^\.\.?$/;
 			if ($file =~ /^robots.txt$/i) {
-			    &util::rm (&util::filename_cat ($importdir, $file));
+			    &FileUtils::removeFiles (&FileUtils::filenameConcatenate ($importdir, $file));
 			    last;
 			} else {
-			    $file = &util::filename_cat ($importdir, $file);
+			    $file = &FileUtils::filenameConcatenate ($importdir, $file);
 			    if (-d $file) {
 				if (opendir (DIR, $file)) {
@@ -304,5 +305,5 @@
 				    foreach my $file2 (@files2) {
 					if ($file2 =~ /^robots.txt$/i) {
-					    &util::rm (&util::filename_cat ($file, $file2));
+					    &FileUtils::removeFiles (&FileUtils::filenameConcatenate ($file, $file2));
 					    last;
 					}
@@ -352,7 +353,7 @@
     my $col_cfg_file;
     if ($gs_mode eq "gs3") {
-	$col_cfg_file = &util::filename_cat($etcdir, "collectionConfig.xml");
+	$col_cfg_file = &FileUtils::filenameConcatenate($etcdir, "collectionConfig.xml");
     } else {
-	$col_cfg_file = &util::filename_cat($etcdir, "collect.cfg");
+	$col_cfg_file = &FileUtils::filenameConcatenate($etcdir, "collect.cfg");
     }
 
@@ -415,5 +416,5 @@
 	    if ((defined $site) && ($site ne ""))
 	    {
-		$install_collectdir = &util::filename_cat ($ENV{'GSDL3HOME'}, "sites", $site, "collect");
+		$install_collectdir = &FileUtils::filenameConcatenate ($ENV{'GSDL3HOME'}, "sites", $site, "collect");
 	    }
 	    else 
@@ -428,5 +429,5 @@
 	else
 	{
-	    $install_collectdir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect");
+	    $install_collectdir = &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "collect");
 	}
 
@@ -435,6 +436,6 @@
 	    # install collection to gsdl/collect
 	    print $out "installing the $collection collection\n";
-	    my $newdir = &util::filename_cat ($install_collectdir, $collection);
-	    my $olddir = &util::filename_cat ($collectdir, $collection);
+	    my $newdir = &FileUtils::filenameConcatenate ($install_collectdir, $collection);
+	    my $olddir = &FileUtils::filenameConcatenate ($collectdir, $collection);
 	    if (-d $newdir) {
 		my $msg = "build: Could not install collection as $newdir\n" .
@@ -494,5 +495,5 @@
 	if ($remove_import) {
 	    print $out "removing import directory ($importdir)\n";
-	    &util::rm_r ($importdir);
+	    &FileUtils::removeFilesRecursive ($importdir);
 	}
     } else {
@@ -540,9 +541,9 @@
     my $build_ok = 0;
     foreach my $db_ext (@db_exts) {
-	if ($removeold && (-e &util::filename_cat ($buildingdir, "text", "$collection$db_ext"))) {
+	if ($removeold && (-e &FileUtils::filenameConcatenate ($buildingdir, "text", "$collection$db_ext"))) {
 	    $build_ok = 1;
 	    last;
 	}
-	if (($removeold==0) && (-e &util::filename_cat ($indexdir, "text", "$collection$db_ext"))) {
+	if (($removeold==0) && (-e &FileUtils::filenameConcatenate ($indexdir, "text", "$collection$db_ext"))) {
 	    $build_ok = 1;
 	    last;
@@ -554,5 +555,5 @@
 	if ($remove_archives) {
 	    print $out "removing archives directory ($archivedir)\n";
-	    &util::rm_r ($archivedir);
+	    &FileUtils::removeFilesRecursive ($archivedir);
 	}
     } else {
@@ -568,5 +569,5 @@
 	if (&has_content ($indexdir)) {
 	    print $out "removing old indexes\n";
-	    &util::rm_r ($indexdir);
+	    &FileUtils::removeFilesRecursive ($indexdir);
 	}
 	rmdir ($indexdir) if -d $indexdir;
@@ -579,5 +580,5 @@
     # remove the cached archives
     if ($save_archives && -d "${archivedir}.org") {
-	&util::rm_r ("${archivedir}.org");
+	&FileUtils::removeFilesRecursive ("${archivedir}.org");
     }
 }
@@ -611,5 +612,5 @@
     $/ = "\n";
     close FILE;
-    &util::rm ($file);
+    &FileUtils::removeFiles ($file);
 }
 
@@ -652,5 +653,5 @@
 	if ($event_log_file eq "" || !open (LOG, ">>$event_log_file")) {
 	    # log file defaults to $GSDLHOME/etc/events.txt
-	    $event_log_file = &util::filename_cat ($ENV{'GSDLHOME'}, "etc", "events.txt");
+	    $event_log_file = &FileUtils::filenameConcatenate ($ENV{'GSDLHOME'}, "etc", "events.txt");
 	    if (!open (LOG, ">>$event_log_file")) {
 		print $out "build: ERROR: Couldn't open event log file $event_log_file\n";
@@ -724,10 +725,10 @@
     if ($make_writable) {
 	# chmod a+rw new collection
-	my $installed_collection = &util::filename_cat($ENV{'GSDLHOME'}, "collect", $collection);
+	my $installed_collection = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "collect", $collection);
 	&recursive_chmod($installed_collection);
 
 	# chmod a+rw anything we've left laying about in the tmp directory
 	if (($collectdir ne "") && 	
-	    (!&util::filenames_equal ($collectdir, &util::filename_cat($ENV{'GSDLHOME'}, "collect")))) {
+	    (!&util::filenames_equal ($collectdir, &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "collect")))) {
 	    &recursive_chmod($collectdir);
 	}
@@ -751,5 +752,5 @@
 	foreach my $file (@files) {
 	    next if $file =~ /^\.\.?$/;
-	    $file = &util::filename_cat($dir, $file);
+	    $file = &FileUtils::filenameConcatenate($dir, $file);
 	    if (-d $file) {
 		&recursive_chmod ($file);
