diff options
author | Andy Dougherty <doughera@lafcol.lafayette.edu> | 1995-02-11 01:17:38 +0000 |
---|---|---|
committer | Andy Dougherty <doughera@lafcol.lafayette.edu> | 1995-02-11 01:17:38 +0000 |
commit | fed7345c45910a20f6865d6a2f8978d09b352f41 (patch) | |
tree | a3147c3565cd04d07489806ee79cd4fb13241223 /lib/File | |
parent | 1aef975c78d2e948679875705c79cbbbddfe5ad7 (diff) | |
download | perl-fed7345c45910a20f6865d6a2f8978d09b352f41.tar.gz |
perl5.000 patch.0k: MakeMaker 4.06 and to fix minor portability and build problems reported even after patches 0a through 0j
MakeMaker 4.06 allows you to build extensions away from the source
tree with either static or dynamic loading.
In a rare act of prescience, I've also fixed some un-reported bugs.
Specifically, there were several places where Configure said you could
specify things using ~name notation, but, in fact, you couldn't.
In detail, here's what's included:
Configure
Check I_SYS_TYPES for x2p/a2p.h
Improve and generalize $osvers detection for DEC Alpha
(now will work even for osvers > 3.)
No longer override hint-file setting of $archname.
Don't tell users ~name is ok for Dynamic loading file. It's not.
MANIFEST
MANIFEST.new
Updated.
Makefile.SH
Some trailing ' ' removed from lines.
New target lib/ExtUtils/Miniperl.pm built. This stashes away
miniperlmain.c in the library so new static extensions can be
built away from the source tree.
Minor cleanup.
U/Oldconfig.pat.2
This is a patch to be applied against dist-PL 50 to upgrade
the DEC OSF/1 version detection.
U/archlib.U
Preserve previous value for $archname. Otherwise this is
identical to the unit in dist-PL 50.
U/dlsrc.U
Users may not use ~name notation to find the dynamic loading
module. (Back in early alpha days they could, but that hasn't
worked since the DynaLoader module was introduced.
config.H
Updated.
config_h.SH
Updated.
hints/dec_osf.sh
Updated. Simplified. Don't use ld -no_archive (at least as
the default). It only worked because some versions *ignored* it.
hints/mpeix.sh
Add a few comments. I should have added more.
hints/next_3_0.sh
New hint file from Kevin White <klwhite@magnus.acs.ohio-state.edu>
hints/ultrix_4.sh
Separate out flags not appropriate for gcc.
installperl
Install sperl.o.
lib/ExtUtils/MakeMaker.pm
Upgraded from 4.03 to 4.06. Many improvements. Now possible
to build and install new extensions outside the source tree,
for both static and dynamic loading.
lib/File/Path.pm
New. Creates or removes a series of directories
makeaperl
New utility to create a new perl binary from static extensions
minimod.PL
New. minimod.PL writes the contents of miniperlmain.c into the
module ExtUtils::Miniperl for later perusal (when the perl
source is deleted)
perl.c
ARCHLIB and PRIVLIB changed to ARCHLIB_EXP and PRIVLIB_EXP,
since perl is not prepared to deal with ~name expansion. The
_EXP variables are pre-expanded by Configure.
proto.h
NeXt 3.0 couldn't handle the #ifdef __attribute line.
It said 'illegal #ifdef'.
vms/config.vms
s/ARCHLIB/ARCHLIB_EXP/;
s/PRIVLIB/PRIVLIB_EXP/;
Add in I_SYS_STAT and I_SYS_TYPES, since the source now looks
for them.
vms/ext/MM_VMS.pm
New file.
x2p/a2p.h
Include <sys/types.h>
Diffstat (limited to 'lib/File')
-rw-r--r-- | lib/File/Path.pm | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/lib/File/Path.pm b/lib/File/Path.pm new file mode 100644 index 0000000000..bafe10828b --- /dev/null +++ b/lib/File/Path.pm @@ -0,0 +1,146 @@ +package File::Mkpath; + +=head1 NAME + +File::Mkpath - create or remove a series of directories + +=head1 SYNOPSIS + +C<use File::Mkpath> + +C<mkpath(['/foo/bar/baz', 'blurfl/quux'], 1, 0711);> + +C<rmtree(['foo/bar/baz', 'blurfl/quux'], 1, 1);> + +=head1 DESCRIPTION + +The C<mkpath> function provides a convenient way to create directories, even if +your C<mkdir> kernel call won't create more than one level of directory at a +time. C<mkpath> takes three arguments: + +=over 4 + +=item * + +the name of the path to create, or a reference +to a list of paths to create, + +=item * + +a boolean value, which if TRUE will cause C<mkpath> +to print the name of each directory as it is created +(defaults to FALSE), and + +=item * + +the numeric mode to use when creating the directories +(defaults to 0777) + +=back + +It returns a list of all directories (including intermediates, determined using +the Unix '/' separator) created. + +Similarly, the C<rmtree> function provides a convenient way to delete a +subtree from the directory structure, much like the Unix command C<rm -r>. +C<rmtree> takes three arguments: + +=over 4 + +=item * + +the root of the subtree to delete, or a reference to +a list of roots. All of the files and directories +below each root, as well as the roots themselves, +will be deleted. For the moment, C<rmtree> expects +Unix file specification syntax. + +=item * + +a boolean value, which if TRUE will cause C<rmtree> to +print a message each time it tries to delete a file, +giving the name of the file, and indicating whether +it's using C<rmdir> or C<unlink> to remove it. +(defaults to FALSE) + +=item * + +a boolean value, which if TRUE will cause C<rmtree> to +skip any files to which you do not have write access. +This will change in the future when a criterion for +'delete permission' is settled. (defaults to FALSE) + +=back + +It returns the number of files successfully deleted. + +=head1 AUTHORS + +Tim Bunce <Tim.Bunce@ig.co.uk> +Charles Bailey <bailey@genetics.upenn.edu> + +=head1 REVISION + +This document was last revised 29-Jan-1995, for perl 5.001 + +=cut + +require 5.000; +use Config; +use Carp; +require Exporter; +@ISA = qw( Exporter ); +@EXPORT = qw( mkpath rmtree ); + +sub mkpath{ + my($paths, $verbose, $mode) = @_; + # $paths -- either a path string or ref to list of paths + # $verbose -- optional print "mkdir $path" for each directory created + # $mode -- optional permissions, defaults to 0777 + local($")="/"; + $mode = 0777 unless defined($mode); + $paths = [$paths] unless ref $paths; + my(@created); + foreach $path (@$paths){ + next if -d $path; + my(@p); + foreach(split(/\//, $path)){ + push(@p, $_); + next if -d "@p/"; + print "mkdir @p\n" if $verbose; + mkdir("@p",$mode) || croak "mkdir @p: $!"; + push(@created, "@p"); + } + } + @created; +} + +sub rmtree { + my($roots, $verbose, $safe) = @_; + my(@files,$count); + $roots = [$roots] unless ref $roots; + + foreach $root (@{$roots}) { + $root =~ s#/$##; + if (-d $root) { + opendir(D,$root); + @files = map("$root/$_", grep $_!~/^\.{1,2}$/, readdir(D)); + closedir(D); + $count += rmtree(\@files,$verbose,$safe); + next if ($safe && !(-w $root)); + print "rmdir $root\n" if $verbose; + (rmdir $root && ++$count) or carp "Can't remove directory $root: $!"; + } + else { + next if ($safe && !(-w $root)); + print "unlink $root\n" if $verbose; + (unlink($root) && ++$count) or carp "Can't unlink file $root: $!"; + } + } + + $count; +} + +1; + +__END__ |