#!/usr/bin/perl # jmc 1999 # Usage: copyinstaller.pl src dest sync use File::Copy; $print = 0; $os = $^O; if (($os eq "linux") || ($os eq "sunos") || ($os eq "solaris")) { $sep = "/"; @files = split(/\//,$dest); } elsif (($os eq "dos") || ($os eq "MSWin32")) { $src = "c:\\temp"; $dest = "c:\\lixo\\ooo\\iii"; $sync_file = "c:\\lixo\\end"; $sep = "\\"; @files = split(/\\/,$dest); } elsif ($os eq "MacOS") { @VOL = &MacPerl'Volumes(); $hd = $VOL[0]; $hd =~ s/\:([^\:]*)$//; $hd = $1; $src = "CLIX-CD:powermac"; $dest = "$hd:clixinstaller"; $sync_file = "$hd:clixinstaller:done_flag"; $sep = ":"; @files = split(/\:/,$dest); } else { exit(1); } $dir = shift(@files); foreach $item (@files) { if ($print) { print "mkdir <$dir$sep$item>\n"; } mkdir("$dir$sep$item",0777); $dir .= "$sep$item"; } &recur(""); open(OUT,">$sync_file"); close(OUT); if ($os eq "MacOS") { &MacPerl'Quit(2); } sub recur { local($dir) = @_; local(@files,$item); opendir(DIR,"$src$dir"); @files = readdir(DIR); closedir(DIR); foreach $item (@files) { if (($item eq ".") || ($item eq "..")) { next; } if (-d "$src$dir$sep$item") { if ($print) { print "mkdir <$dest$dir$sep$item>\n"; } mkdir("$dest$dir$sep$item",0777); &recur("$dir$sep$item"); } else { if ($print) { print "copy \"$src$dir$sep$item\" \"$dest$dir$sep$item\"\n"; } copy("$src$dir$sep$item","$dest$dir$sep$item"); } } }