diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2003-07-25 10:52:58 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2003-07-25 10:52:58 +0000 |
commit | 90ccb2b7b2ed97e15b450d4c4316d363b3f2f228 (patch) | |
tree | 2dd6279a9e4fdd11e0ed0811725c9967b9183b41 /readlicense_oo | |
parent | a0a35515579e88e4ca48b287c0a8742399a60ab5 (diff) |
INTEGRATION: CWS readlic (1.1.2); FILE ADDED
2003/07/24 14:12:14 bei 1.1.2.1: #i12359#
Diffstat (limited to 'readlicense_oo')
-rwxr-xr-x | readlicense_oo/conv.pl | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/readlicense_oo/conv.pl b/readlicense_oo/conv.pl new file mode 100755 index 000000000000..24568188230e --- /dev/null +++ b/readlicense_oo/conv.pl @@ -0,0 +1,97 @@ +#!/usr/bin/perl + +use strict; +use File::Find (); +use File::Basename (); +use File::Path (); +use Getopt::Std; +use Cwd; + +my ($startdir,$outdir,$pfx); + +sub usage() { + print STDERR "usage: $0 -o <outdir> [-f <file>]\n" +} + +$startdir=cwd(); + +# for the convenience of &wanted calls, including -eval statements: +use vars qw/*name *dir *prune/; +*name = *File::Find::name; +*dir = *File::Find::dir; +*prune = *File::Find::prune; + +if ( !getopts('o:f:') ) { + usage(); + exit(1); +} + +if ( defined($Getopt::Std::opt_o) ) { + $outdir=$Getopt::Std::opt_o; + $outdir=~s%\\%/%g; +} else { + usage(); + exit(1); +} + +if ( defined($Getopt::Std::opt_f) ) { + convertfile($outdir,$Getopt::Std::opt_f); +} else { + # Traverse desired filesystems + $pfx="source"; + File::Find::find({wanted => \&wanted}, 'source'); +} +exit; + + +sub wanted { + my ($dev,$ino,$mode,$nlink,$uid,$gid); + + ( + /^.*\.html\z/s + || + /^license\.txt\z/s + || + /^LICENSE\z/s + || + /^readme\.txt\z/s + || + /^README\z/s + ) && + ($nlink || (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_))) && + eval {&doconv}; +} + +sub doconv { + my($dest); + $dest=$dir; + $dest=~s/^$pfx//g; + $dest=$outdir.$dest; + convertfile($dest,$name); +} + +sub convertfile { + my ($dest,$file,$destfile); + $dest=shift; + $file=shift; + $dest=~s%^./%%g; + $dest=$startdir . "/" . $dest; + $file=$startdir . "/" . $file; + + $destfile=$dest . "/" . File::Basename::basename($file); + + File::Path::mkpath($dest,0,0755); + + open(IN,"<$file") || die "can not open $file"; + open(OUT,">$destfile") || die "can not open $destfile"; + + while (<IN> ) { + chop while ( /\n$/ || /\r$/ ); + print OUT "$_\n"; + } + close(IN); + close(OUT); +} + + + |