Cleanup the File::Spec tmpdir() implementations:
[p5sagit/p5-mst-13.2.git] / lib / File / Spec / Cygwin.pm
CommitLineData
07824bd1 1
ecf68df6 2package File::Spec::Cygwin;
3
4use strict;
5use vars qw(@ISA $VERSION);
6require File::Spec::Unix;
7
8$VERSION = '1.0';
9
10@ISA = qw(File::Spec::Unix);
11
07824bd1 12=head1 NAME
13
14File::Spec::Cygwin - methods for Cygwin file specs
15
16=head1 SYNOPSIS
17
18 require File::Spec::Cygwin; # Done internally by File::Spec if needed
19
20=head1 DESCRIPTION
21
22See File::Spec::Unix for a documentation of the methods provided
23there. This package overrides the implementation of these methods, not
24the semantics.
25
26This module is still in beta. Cygwin-knowledgeable folks are invited
27to offer patches and suggestions.
28
29=cut
30
31=pod
32
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;
43 return $self->SUPER::canonpath($path);
44}
45
07824bd1 46=pod
47
48=item file_name_is_absolute
49
50True is returned if the file name begins with C<drive_letter:>,
51and if not, File::Spec::Unix file_name_is_absolute() is called.
52
53=cut
54
55
3ed25742 56sub file_name_is_absolute {
57 my ($self,$file) = @_;
58 return 1 if $file =~ m{^([a-z]:)?[\\/]}is; # C:/test
59 return $self->SUPER::file_name_is_absolute($file);
60}
61
07824bd1 62=item tmpdir (override)
f534ab20 63
07824bd1 64Returns a string representation of the first existing directory
65from the following list:
ecf68df6 66
07824bd1 67 $ENV{TMPDIR}
68 /tmp
69 C:/temp
ecf68df6 70
07824bd1 71Since Perl 5.8.0, if running under taint mode, and if the environment
72variables are tainted, they are not used.
ecf68df6 73
07824bd1 74=cut
ecf68df6 75
07824bd1 76my $tmpdir;
77sub tmpdir {
78 return $tmpdir if defined $tmpdir;
79 my $self = shift;
80 $tmpdir = $self->_tmpdir( $ENV{TMPDIR}, "/tmp", 'C:/temp' );
81}
ecf68df6 82
07824bd1 831;