Upgrade to PathTools-3.24.
[p5sagit/p5-mst-13.2.git] / lib / File / Spec / Cygwin.pm
CommitLineData
ecf68df6 1package File::Spec::Cygwin;
2
3use strict;
4use vars qw(@ISA $VERSION);
5require File::Spec::Unix;
6
6f0dcf97 7$VERSION = '1.1';
ecf68df6 8
9@ISA = qw(File::Spec::Unix);
10
07824bd1 11=head1 NAME
12
13File::Spec::Cygwin - methods for Cygwin file specs
14
15=head1 SYNOPSIS
16
17 require File::Spec::Cygwin; # Done internally by File::Spec if needed
18
19=head1 DESCRIPTION
20
72f15715 21See L<File::Spec> and L<File::Spec::Unix>. This package overrides the
22implementation of these methods, not the semantics.
07824bd1 23
24This module is still in beta. Cygwin-knowledgeable folks are invited
25to offer patches and suggestions.
26
27=cut
28
29=pod
30
95fb0f99 31=over 4
32
07824bd1 33=item canonpath
34
35Any C<\> (backslashes) are converted to C</> (forward slashes),
36and then File::Spec::Unix canonpath() is called on the result.
37
38=cut
39
ecf68df6 40sub canonpath {
41 my($self,$path) = @_;
42 $path =~ s|\\|/|g;
e9475de8 43
44 # Handle network path names beginning with double slash
45 my $node = '';
46 if ( $path =~ s@^(//[^/]+)(?:/|\z)@/@s ) {
47 $node = $1;
48 }
49 return $node . $self->SUPER::canonpath($path);
ecf68df6 50}
51
9d5071ba 52sub catdir {
53 my $self = shift;
54
55 # Don't create something that looks like a //network/path
56 if ($_[0] eq '/' or $_[0] eq '\\') {
57 shift;
58 return $self->SUPER::catdir('', @_);
59 }
60
61 $self->SUPER::catdir(@_);
62}
63
07824bd1 64=pod
65
66=item file_name_is_absolute
67
68True is returned if the file name begins with C<drive_letter:>,
69and if not, File::Spec::Unix file_name_is_absolute() is called.
70
71=cut
72
73
3ed25742 74sub file_name_is_absolute {
75 my ($self,$file) = @_;
76 return 1 if $file =~ m{^([a-z]:)?[\\/]}is; # C:/test
77 return $self->SUPER::file_name_is_absolute($file);
78}
79
07824bd1 80=item tmpdir (override)
f534ab20 81
07824bd1 82Returns a string representation of the first existing directory
83from the following list:
ecf68df6 84
07824bd1 85 $ENV{TMPDIR}
86 /tmp
87 C:/temp
ecf68df6 88
07824bd1 89Since Perl 5.8.0, if running under taint mode, and if the environment
90variables are tainted, they are not used.
ecf68df6 91
07824bd1 92=cut
ecf68df6 93
07824bd1 94my $tmpdir;
95sub tmpdir {
96 return $tmpdir if defined $tmpdir;
60598624 97 $tmpdir = $_[0]->_tmpdir( $ENV{TMPDIR}, "/tmp", 'C:/temp' );
07824bd1 98}
ecf68df6 99
95fb0f99 100=back
101
99f36a73 102=head1 COPYRIGHT
103
104Copyright (c) 2004 by the Perl 5 Porters. All rights reserved.
105
106This program is free software; you can redistribute it and/or modify
107it under the same terms as Perl itself.
108
95fb0f99 109=cut
110
07824bd1 1111;