maketree.perl 930 Bytes
#! /usr/sbin/perl
#----------------------------------------------------------------------#
#	Copyright (C) 1997, Nintendo.
#	
#	File		maketree.perl
#	Coded    by	Yoshitaka Yasumoto.	Oct  9, 1997.
#	Modified by	
#	
#	$Id: maketree.perl,v 1.1.1.1 2002/05/02 03:29:12 blythe Exp $
#----------------------------------------------------------------------#

if ($ARGV[1] eq $ARGV[2]){
    print("Error: $ARGV[1] and $ARGV[2] is same directories.\n");
    exit(1);
}

open(FILE, "$ARGV[0]") || die "Cannot open $ARGV[0]\n";

while (<FILE>){
    if ( /^\s*i*pi*\s+([tb])\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)$/ ){
	$from = "$ARGV[1]/$4";
	$to   = "$ARGV[2]/$4";
	($todir, $tofile) = $to =~ m#^(.*)/(.*)$#;
	if (! -d $todir){
	    system("mkdir -p $todir");
	}	
	if ($1 eq "t"){
	    system("nkf -s $from > $to.tmp; to_dos $to.tmp $to; rm $to.tmp");
	} else {
	    system("cp $from $todir");
	}
    }
}

#======== End of maketree.perl ========#