xref: /openbsd-src/gnu/usr.bin/perl/dist/PathTools/lib/File/Spec/Functions.pm (revision ea1cb3a083ca71ebc0de9fb1cda141e17829957c)
1package File::Spec::Functions;
2
3use File::Spec;
4use strict;
5
6use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);
7
8$VERSION = '3.48_02';
9$VERSION =~ tr/_//;
10
11require Exporter;
12
13@ISA = qw(Exporter);
14
15@EXPORT = qw(
16	canonpath
17	catdir
18	catfile
19	curdir
20	rootdir
21	updir
22	no_upwards
23	file_name_is_absolute
24	path
25);
26
27@EXPORT_OK = qw(
28	devnull
29	tmpdir
30	splitpath
31	splitdir
32	catpath
33	abs2rel
34	rel2abs
35	case_tolerant
36);
37
38%EXPORT_TAGS = ( ALL => [ @EXPORT_OK, @EXPORT ] );
39
40require File::Spec::Unix;
41my %udeps = (
42    canonpath => [],
43    catdir => [qw(canonpath)],
44    catfile => [qw(canonpath catdir)],
45    case_tolerant => [],
46    curdir => [],
47    devnull => [],
48    rootdir => [],
49    updir => [],
50);
51
52foreach my $meth (@EXPORT, @EXPORT_OK) {
53    my $sub = File::Spec->can($meth);
54    no strict 'refs';
55    if (exists($udeps{$meth}) && $sub == File::Spec::Unix->can($meth) &&
56	    !(grep {
57		File::Spec->can($_) != File::Spec::Unix->can($_)
58	    } @{$udeps{$meth}}) &&
59	    defined(&{"File::Spec::Unix::_fn_$meth"})) {
60	*{$meth} = \&{"File::Spec::Unix::_fn_$meth"};
61    } else {
62	*{$meth} = sub {&$sub('File::Spec', @_)};
63    }
64}
65
66
671;
68__END__
69
70=head1 NAME
71
72File::Spec::Functions - portably perform operations on file names
73
74=head1 SYNOPSIS
75
76	use File::Spec::Functions;
77	$x = catfile('a','b');
78
79=head1 DESCRIPTION
80
81This module exports convenience functions for all of the class methods
82provided by File::Spec.
83
84For a reference of available functions, please consult L<File::Spec::Unix>,
85which contains the entire set, and which is inherited by the modules for
86other platforms. For further information, please see L<File::Spec::Mac>,
87L<File::Spec::OS2>, L<File::Spec::Win32>, or L<File::Spec::VMS>.
88
89=head2 Exports
90
91The following functions are exported by default.
92
93	canonpath
94	catdir
95	catfile
96	curdir
97	rootdir
98	updir
99	no_upwards
100	file_name_is_absolute
101	path
102
103
104The following functions are exported only by request.
105
106	devnull
107	tmpdir
108	splitpath
109	splitdir
110	catpath
111	abs2rel
112	rel2abs
113	case_tolerant
114
115All the functions may be imported using the C<:ALL> tag.
116
117=head1 COPYRIGHT
118
119Copyright (c) 2004 by the Perl 5 Porters.  All rights reserved.
120
121This program is free software; you can redistribute it and/or modify
122it under the same terms as Perl itself.
123
124=head1 SEE ALSO
125
126File::Spec, File::Spec::Unix, File::Spec::Mac, File::Spec::OS2,
127File::Spec::Win32, File::Spec::VMS, ExtUtils::MakeMaker
128
129=cut
130
131