The "reduce memory footprint and increase speed by not
[p5sagit/p5-mst-13.2.git] / lib / File / Spec / Cygwin.pm
1 package File::Spec::Cygwin;
2
3 use strict;
4 use vars qw(@ISA $VERSION);
5 require File::Spec::Unix;
6
7 $VERSION = '1.1';
8
9 @ISA = qw(File::Spec::Unix);
10
11 =head1 NAME
12
13 File::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
21 See L<File::Spec> and L<File::Spec::Unix>.  This package overrides the
22 implementation of these methods, not the semantics.
23
24 This module is still in beta.  Cygwin-knowledgeable folks are invited
25 to offer patches and suggestions.
26
27 =cut
28
29 =pod
30
31 =item canonpath
32
33 Any C<\> (backslashes) are converted to C</> (forward slashes),
34 and then File::Spec::Unix canonpath() is called on the result.
35
36 =cut
37
38 sub canonpath {
39     my($self,$path) = @_;
40     $path =~ s|\\|/|g;
41     return $self->SUPER::canonpath($path);
42 }
43
44 =pod
45
46 =item file_name_is_absolute
47
48 True is returned if the file name begins with C<drive_letter:>,
49 and if not, File::Spec::Unix file_name_is_absolute() is called.
50
51 =cut
52
53
54 sub file_name_is_absolute {
55     my ($self,$file) = @_;
56     return 1 if $file =~ m{^([a-z]:)?[\\/]}is; # C:/test
57     return $self->SUPER::file_name_is_absolute($file);
58 }
59
60 =item tmpdir (override)
61
62 Returns a string representation of the first existing directory
63 from the following list:
64
65     $ENV{TMPDIR}
66     /tmp
67     C:/temp
68
69 Since Perl 5.8.0, if running under taint mode, and if the environment
70 variables are tainted, they are not used.
71
72 =cut
73
74 my $tmpdir;
75 sub tmpdir {
76     return $tmpdir if defined $tmpdir;
77     my $self = shift;
78     $tmpdir = $self->_tmpdir( $ENV{TMPDIR}, "/tmp", 'C:/temp' );
79 }
80
81 1;