home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Updates / Perl / Non-RPC / !Perl / scripts / getSource < prev    next >
Text File  |  1998-09-12  |  1KB  |  45 lines

  1. #! perl
  2. die "$0 <UnixSourceDir> <RISCOSDestDir>\n" if( $#ARGV < 1 );
  3. use RISCOS;
  4.  
  5. $sourcedir = $ARGV[0];
  6. $destdir = $ARGV[1];
  7.  
  8. foreach( 'CC', 'cc', 'C', 'c', 'h', 'H', 's', 'S' )
  9. {
  10.   $ext{ $_ } = $_;    # Hash directory name by suffix
  11.             # (Currently dirname == suffix )
  12. }
  13.  
  14. $ext{ 'cpp' } = 'cc';
  15. $ext{ 'CPP' } = 'cc';
  16. $ext{ 'HPP' } = 'h';    # Some people use this suffix for C++ headers
  17. $ext{ 'hpp' } = 'h';
  18.  
  19. opendir( MYDIR, $sourcedir )
  20.     || die "Couldn't open directory $sourcedirname\n";
  21.  
  22. foreach $file ( readdir( MYDIR ) )
  23. {
  24.     if ($file =~ /makefile/i) {
  25.     print "$file -> $file\n";
  26.     RISCOS::File::copy "$sourcedir.$file", "$destdir.$file", 0x102 or print STDERR "$!\n";
  27.     } else {
  28.     ( $base, $ext ) = ( $file =~ m#^([^/]*)/([^/]*)$#);
  29.     if( defined $ext{ $ext } )    # Clasic variable naming scheme 8-)
  30.     {
  31.         # We have but one extension, and it's in our list!
  32.         $destsubdir = "$destdir.$ext{$ext}";
  33. #    print "$destsubdir\n";
  34.         mkdir( $destsubdir, 511 ) unless -d $destsubdir;
  35.  
  36.         $source = "$sourcedir.$file";
  37.         $dest = "$destsubdir.$base";
  38.         print "$file -> $ext.$base\n";
  39.         RISCOS::File::copy $source, $dest, 0x102 or print STDERR "$!\n";
  40. #    print "*copy $source $dest ~c\n";
  41.     }
  42.     }
  43. }
  44.  
  45.